You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

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.

/plugins/my_plugin/views/default/client_main.pdt
<?php
$this->Widget->clear();
$this->Widget->create();

#
# TODO: Place widget contents here
#

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

In the example above we do three things:

  1. On line 2 we clear the widget using theclear() method. This allows us to ensure that our widget is in its default state.
  2. On line 3 we begin the widget with create().
  3. 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

 

 

 

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 to each link.

Allow the theme to override the color of your links
...
<a class="override" href="/">Click me!</a>
...
  • No labels