Creating a View Template

The next step is to create a view template for the indexAction() method. This template is a text file that belongs in ./templates/index.tpl in your widget directory. This template must be written using HTML and Smarty Template Engine markup.

Technically you can use whatever markup you like in this file, but to use the standard Control Panel display all your markup should be within {widget} Smarty tag. This is a built-in plug-in used to help creating widget templates.

If you want a row of buttons at the top of your widget (beneath the wiget title and control buttons), use the {widget_buttonpane header=true} Smarty tag.

Likewise, if you want a row of buttons at the bottom of your widget use the {widget_buttonpane footer=true} Smarty tag.

To add a button, use the {button} Smarty tag.

Any content that lies between button panes (or even if there are no button panes) should lie within {widget_content} tags.

Below is a sample template. It makes uses of the $someData variable we assigned in the controller.php file.

Example 2.2. Sample widget view template (index.tpl)

    {widget_buttonpane header=true}
        {button name='foo'}Show Alert{/button}

        someData variable: {$someData|escape}

Now when you add your widget you will see some more useful information.