Rendering UI Elements
url
We recommend using the url
helper for creating links.
Controller:
$this->view->uplevelLink = $this->_helper->url('action', 'controller');
View:
<a href="<?php echo $this->url(array(
'controller' => 'index',
'action' => 'index',
)); ?>">Link</a>
lmsg
Output of localized messages.
Controller:
$this->view->message = $this->lmsg('helloMessage');
View:
<b><?php echo $this->lmsg('helloMessage'); ?></b>
renderList
Rendering of lists.
Controller:
private function _getNumbersList()
{
$data = array();
$iconPath = pm_Context::getBaseUrl() . 'images/icon_16.gif';
for ($index = 1; $index < 150; $index++) {
$data[] = array(
'column-1' => '<a href="#">link #' . $index . '</a>',
'column-2' => '<img src="/' . $iconPath . '" /> image #' . $index,
);
}
$list = new pm_View_List_Simple($this->view, $this->_request);
$list->setData($data);
$list->setColumns(array(
'column-1' => array(
'title' => 'Link',
'noEscape' => true,
'searchable' => true,
),
'column-2' => array(
'title' => 'Description',
'noEscape' => true,
'sortable' => false,
),
));
$list->setTools(array(
array(
'title' => 'Example',
'description' => 'Example module with UI samples',
'class' => 'sb-app-info',
'link' => pm_Context::getBaseUrl(),
),
array(
'title' => 'Modules',
'description' => 'Modules installed in the Panel',
'class' => 'sb-suspend',
'link' => pm_Context::getModulesListUrl(),
),
);
// Take into account listDataAction corresponds to the URL /list-data/
$list->setDataUrl(array('action' => 'list-data'));
return $list;
}
public function listAction()
{
$list = $this->_getNumbersList();
// List object for pm_View_Helper_RenderList
$this->view->list = $list;
}
public function listDataAction()
{
$list = $this->_getNumbersList();
// Json data from pm_View_List_Simple
$this->_helper->json($list->fetchData());
}
View:
<?php echo $this->renderList($this->list); ?>
renderTools
Rendering of buttons.
Controller:
$this->view->tools = array(
array(
'icon' => pm_Context::getBaseUrl() . "img/site-aps_32.gif",
'title' => 'Example',
'description' => 'Example extension with UI samples',
'link' => pm_Context::getBaseUrl(),
),
array(
'icon' => pm_Context::getBaseUrl() . "img/modules_32.gif",
'title' => 'Extensions',
'description' => 'Extensions installed in the Panel',
'link' => pm_Context::getModulesListUrl(),
),
);
View:
<?php echo $this->renderTools($this->tools); ?>
renderSmallTools
Rendering of small buttons.
Controller:
$this->view->smallTools = array(
array(
'title' => 'Example',
'description' => 'Example module with UI samples',
'class' => 'sb-app-info',
'link' => pm_Context::getBaseUrl(),
),
array(
'title' => 'Modules',
'description' => 'Modules installed in the Panel',
'class' => 'sb-suspend',
'link' => pm_Context::getModulesListUrl(),
),
);
View:
<?php echo $this->renderSmallTools($this->smallTools); ?>
renderTabs
Rendering of tabs.
Controller:
$this->view->tabs = array(
array(
'title' => 'Form',
'action' => 'form',
),
array(
'title' => 'Tools',
'action' => 'tools',
),
array(
'title' => 'List',
'action' => 'list',
),
);
View:
<?php echo $this->renderTabs($this->tabs); ?>