The upcoming release 1.1.0 will introduce a new “widget” system for Pligg. This new feature has been added to make managing your Pligg site from the Pligg Admin Panel an easier process. The Admin Panel homepage will be replaced with a new widget interface, which will allow you to customize the information that appears when you log into the Admin Panel.
Pligg widgets can be installed, removed, and organized very easily. Widgets will have their own management page where you install and uninstall them, similar to the existing Module Management page. Once you have installed a widget, you will see it appear on the top left area of your Admin Panel homepage. By left-clicking and holding on the widget title bar, you can drag-and-drop a widget box from one spot to another. This allows you to organize the widgets in an order that makes sense to you. Widgets can be minimized by clicking on the a minimize icon located in the widget title bar, although not all widgets will allow this.
Widgets differ from Pligg modules, because they are designed to only display data to administrators through the Admin Panel homepage. Widgets can be used in combination with a module to accomplish more advanced features. One example of this is the Akismet module and widget. The Akismet module adds an extra level of spam protection to your site by checking new stories and comments for bad content. The Akismet widget acts as an Admin Panel notice where you will receive an alert when Akismet has marked a story or comment as spam.
For developers, the new widget feature adds a lot of possibilities. Widgets offer a very simple way to add tools to your Admin Panel interface. You can write a module with as little as two files (init.php and widget.tpl) totaling only 10 lines. Widgets are based on two template files, stored in the widget’s template directory, and an init.php file that stores common widget settings and any PHP code that your widget may require.
The first widget template file is settings.tpl, which is responsible for any settings that your widget might have. Users access the settings.tpl file when they click on the wrench icon located in the widget title bar. Example uses for this file might be to have a user enter an API key or login details for a third party site. We recognize that not all widgets will need to be configured in this way, which is why the settings.tpl file is entirely optional. If your widget does not require the settings.tpl file you can disable the settings feature from the widget’s init.php file.
The second widget template file is widget.tpl. This controls the main widget content that appears when you are on the Admin Panel homepage. Pligg automatically places the content for both this template and the settings template inside of a widget box. This means that developers don’t have to think about the widget design, keeping the layout and style separate from the code.
The last file that you should learn about is the init.php file. This file is used by all widgets, and is similar to the MODULE_init.php files already being used by Pligg modules. The init.php file is stores common configuration values for widgets such as the widget name, description, version number, and other options. Below is an example of a widget init.php file.
$widget['widget_title'] = "Example Widget";
$widget['widget_has_settings'] = 0;
$widget['widget_shrink_icon'] = 1;
$widget['widget_uninstall_icon'] = 1;
$widget['name'] = 'Example';
$widget['desc'] = 'Here is a widget description.';
$widget['version'] = 1.0;