User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Creating Sidebar in the statement

 

Started, visit the entry page views then open the folder is the folder in view.html.php hellos edit function display.

com_helloworld/views/hellos/view.html.php

function display($tpl = null) 
{
        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');
        $this->state = $this->get('State');

        $this->addToolbar();
        $this->sidebar = JHtmlSidebar::render(); // เพิ่มบรรทัดนี้เข้ามา
        parent::display($tpl);
}

 

Go into the folder tmpl default.php file editing. 

com_helloworld/views/hellos/tmpl/default.php.

<?php if (!empty($this->sidebar)) { ?>
      <div id="j-sidebar-container" class="span2">
                <?php echo $this->sidebar; ?>
        </div>
<?php } ?>
<div id="j-main-container"<?php echo !empty($this->sidebar) ? ' class="span10"' : ''; ?>>

 

Add the following line of code to open the tag form.

<form action="<?php echo JRoute::_('index.php?option=com_helloworld&c=hello');?>" method="post" name="adminForm" id="adminForm">
        <?php if (!empty($this->sidebar)) { ?>
                <div id="j-sidebar-container" class="span2">
                        <?php echo $this->sidebar; ?>
                </div>
        <?php } ?>
        <div id="j-main-container"<?php echo !empty($this->sidebar) ? ' class="span10"' : ''; ?>>
        <div id="filter-bar" class="btn-toolbar">

Tested on the page will see the Sidebar on the left in the listing page.

 

Creating a menu in the Sidebar

Object JHtmlSidebar start using helpers to create the folder in a folder or component com_helloworld finished helper.php file and enter the code.

<?php
defined('_JEXEC') or die('Restricted access');

class Helper 
{
        function addSubmenu($vName) 
        {
               
                JHtmlSidebar::addEntry(
                    JText::_('COM_HELLOWORLD_HELLO'),
                    'index.php?option=com_helloworld&c=hello',
                    $vName == 'hello'
                );

                JHtmlSidebar::addEntry(
                    JText::_('COM_HELLOWORLD_IMG'),
                    'index.php?option=com_helloworld&c=img',
                    $vName == 'img'
                );
        }
}

 

Then open Sidebar view.html.php put the amendment.

com_helloworld/views/hellos/view.html.php

function display($tpl = null) 
{
        $helper = new Helper();
        $helper->addSubmenu('hello');

        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');
        $this->state = $this->get('State');

        $this->addToolbar();
        $this->sidebar = JHtmlSidebar::render();
        parent::display($tpl);

 

Creating the Sidebar Filter

Then open Sidebar view.html.php put the amendment on function addToolbar. 

com_helloworld /views/hellos/view.html.php.

function addToolbar() 
{
    JToolbarHelper::title(JText::_('COM_HELLOWORLD_HELLO_HELLO_LIST'));
    JToolbarHelper::addNew('add');
    JToolbarHelper::editList('edit');
    JToolbarHelper::deleteList('Are you sure?', 'delete');
    JHtmlSidebar::setAction('index.php?option=com_helloworld&c=hello');
    JHtmlSidebar::addFilter(
            JText::_('JOPTION_SELECT_PUBLISHED'),
            'filter_published',
            JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)
    );

 

Display:

 

Chapter 17 - Creating the Config - Component Development