Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Window decorations are set on the title bar of the widget. There are currently two three types of window decorations: arrow, setting, and setting full_screen. The arrow decorations allows the widget to be minimized and restored, while the setting decoration may be linked another page or URI loaded via AJAX. The full_screen decoration adds a button which allows this widget to expand to the full width of the browser window.

Code Block
languagephp
title/plugins/my_plugin/views/default/client_main.pdt
linenumberstrue
<?php
$this->Widget->clear();
// Allow the widget to be minimized
$this->Widget->setWidgetButton("arrow");
// Allow this widget's setting to be updated using ClientMain::settings()
$this->Widget->setWidgetButton(array('class' => "setting ajax", 'href' => $this->base_uri . "widget/my_plugin/client_main/settings/"));
$this->Widget->create("My Widget Title", array('id' => "my_widget_id", 'class' => "my_widget_class"), "full");

#
# TODO: Place widget contents here
#

$this->Widget->end();
?>

...

The renderAjaxWidgetIfAsync() method will automatically determine the format of the response and act accordingly.

Widgets may set tabs or links to appear at the top of the widget to swap content.

When tabs are set, each must include three attributes, namely: name, current, and attributes. The name is the display name of the tab. Current is whether or not the tab is currently selected, and attributes are additional attributes to include on the anchor tag of the tab, such as the href.

Code Block
languagephp
<?php
	$tabs = array(
		array('name'=>"Settings", 'attributes'=>array('href'=>$this->base_uri . "widget/my_plugin/client_main/settings/")),
		array('name'=>"Manage", 'current'=>true, 'attributes'=>array('href'=>$this->base_uri . "widget/my_plugin/client_main/manage/"))
	);

	$this->Widget->clear();
	$this->Widget->setTabs($tabs);    
	$this->Widget->create("My Widget Title", true));

	#
	# TODO: Place widget contents here
	# 

	$this->Widget->end();
?>

 

Links may be used in place of tabs, and may accompany link buttons. Links are displayed at the top left of a widget while link buttons are displayed at the top right. Links may also specify an "ajax" class to allow the widget content to be replaced via AJAX content from the specified href.

Code Block
languagephp
<?php
	$links = array(
		array('name'=>"Settings", 'current'=>true, 'attributes'=>array('href'=>$this->base_uri . "widget/my_plugin/client_main/settings/", 'class'=>"ajax")),
		array('name'=>"Manage", 'attributes'=>array('href'=>$this->base_uri . "widget/my_plugin/client_main/manage/", 'class'=>"ajax"))
	);
	$link_buttons = array(
		array('name'=>"Add Setting", 'attributes'=>array("href"=>$this->Html->safe($this->base_uri . "widget/my_plugin/client_main/settings/add/")))
	);
        
	$this->Widget->clear();
	$this->Widget->setLinks($links);
	$this->Widget->setLinkButtons($link_buttons);
	$this->Widget->create("My Widget Title", true));

	#
	# TODO: Place widget contents here
	# 

	$this->Widget->end();
?>

 

Widgets and Plugins

Widgets can appear anywhere within your plugin, but Blesta reserves a few Plugin Actions especially for rendering widgets. These actions will automatically load your widgets to display in various locations (if the Staff member has enabled the widget to appear). This allows plugins to display custom data/forms on pages that plugins can't otherwise access. For more information on registering your widgets with these actions see the Plugin Actions section of this manual.

...