A widget is an interface element that can contain just about anything. To help create widgets we've designed the Widget helper, which is automatically loaded for all views created in a controller that inherits (either directly or indirectly) from AppController.
The Structure
Every widget needs at least two things: a beginning, and an end.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?php
$this->Widget->clear();
$this->Widget->create();
#
# TODO: Place widget contents here
#
$this->Widget->end();
?> |
In the example above we do three things:
- On line 2 we clear the widget using theclear() method. This allows us to ensure that our widget is in its default state.
- On line 3 we begin the widget with create().
- On line 9 we end the widget with end().
The create() method accepts a few parameters, described below:
- $title - The title to display for the widget window
- $attributes - An array of HTML attributes to set for the widget's primary container (e.g. array('id' => "my_widget_id", 'class' => "my_widget_class")).
- $render - The are of the widget to render. This is necessary when renderings widgets via AJAX, so you can control the content that's replaced. Acceptable values include:
- 'full' - The default value, will render the entire widget
- 'content_section' - The full content including navigation (everything excluding box frame and title section)
- 'common_box_content' - The content only ('content_section' excluding the navigation)
Window Decorations
Tabs and Links
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.
Theme Options
You can enable links in your widgets to be themed by Blesta by adding the "override" class
Configure for the Current Theme
The color of links in your plugin can be overridden by theme set in Blesta by adding a class "override" to each link.
Code Block | ||||
---|---|---|---|---|
| ||||
... <a class="override" href="/">Click me!</a> ... |