I can't find any tutorials on how to use the JHtmlSidebar
Utility Class.
This comes close to it: Creating a toolbar for your component, but it is very vague. It mentions $this->sidebar
, which suggest that the View class should have an attribute sidebar. But sidebar attribute doesn't exist in the View class.
I tried using this:
JHtmlSidebar::addEntry('test','test',0);
echo $this->sidebar = JHtmlSidebar::render();
It does indeed echo the sidebar, but it sits at top or bottom of my view, not on the side. I'm just wondering if there is a way to let Joomla do the rendering for me, instead of creating my own layout.
Some help or links to useful tutorial on the use of admin side bar would be much appreciated. Thank you.
com_helloworld/views/helloworld/view.html.php:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');
class HelloWorldViewHelloWorld extends JViewLegacy {
public function display($tpl = NULL){
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
}
}
protected function addToolbar(){
require_once JPATH_COMPONENT . '/helpers/helloworld .php';
JToolBarHelper::title( 'Hello World', 'helloworld' );
JToolBarHelper::addNew();
JToolBarHelper::deleteList();
JToolBarHelper::editList();
JToolBarHelper::preferences('com_helloworld', '500');
xProfileHelper::addSubmenu('helloworld');
}
}
com_helloworld/helpers/helloworld.php:
class HelloWorldHelper extends JHelperContent
{
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
'test',
'index.php?option=com_helloworld&view=helloworld',
$vName == 'profile'
);
}
}