JHtmlSidebar renders my entries 4 times for some reason !?

92 views
Skip to first unread message

John Curious

unread,
Aug 9, 2018, 8:07:30 AM8/9/18
to Joomla! General Development
Please help me, I don't know what's going on.
I have followed the helloworld component tutorial.
I have this Helper/com_helloworld where I just define a public function addSubmenu
```
public function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
Text::_('COM_OWR'),
'index.php?option=com_owr&view=owr',
$vName == 'owr_main');
```

then in my main controller I just use a Base Controller to getInstance and getApplication task
```
$controller = BaseController::getInstance('owr');
$controller->execute(Factory::getApplication()->input->get('task'));
$controller->redirect();
```

and my view

```
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
```

for some reason the output is four entries identical with the link from the helper function addSubmenu...
Has this ever happened to anyone ??

Maciek Wołpiuk

unread,
Aug 9, 2018, 8:09:35 AM8/9/18
to joomla-de...@googlegroups.com
Hello

What U put in view.html.php file for this view?

Pozdr
Maciek


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

John Curious

unread,
Aug 9, 2018, 8:16:55 AM8/9/18
to Joomla! General Development
first of all, thank you for replying. You're very kind.
Second, my view.html.php for the main view (owr) looks like this:

public function display($tpl = null)
  {
    // Show the toolbar
    $this->toolbar();

    // Show the sidebar
    $this->helper = new OwrHelper;
    $this->helper->addSubmenu('owr_main');
    $this->helper->addSubmenu('owr_options');
    $this->sidebar = JHtmlSidebar::render();

    // Display it all
    return parent::display($tpl);
  }

  /**
   * Displays a toolbar for a specific page.
   *
   * @return void.
   *
   * @since 1.0
   */
  private function toolbar()
  {
    JToolBarHelper::title(Text::_('COM_OWR'), '');
    JToolBarHelper::title(Text::_('COM_OWR_CONFIGURATION'), '');

    // Options button.
    if (Factory::getUser()->authorise('core.admin', 'com_owr'))
    {
      JToolBarHelper::preferences('com_owr');
      JToolBarHelper::preferences('com_owr_configuration');
    }
  }
}

To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.

John Curious

unread,
Aug 9, 2018, 8:18:43 AM8/9/18
to Joomla! General Development
Later edit: While answering to your post, I figured out what the problem was. I had there too many addSubmenu()s. Seems to me like I only need one call to the function here, and in the function I addEntry four times. Thanks very much

Maciek Wołpiuk

unread,
Aug 9, 2018, 8:19:58 AM8/9/18
to joomla-de...@googlegroups.com
Wrong.

this is from my view for name galleries.

RRRGalleryHelper::addSubmenu('galleries');


abstract class RRRGalleryHelper extends JHelperContent
{
/**
* Configure the Linkbar.
*
* @return Bool
*/

public static function addSubmenu($submenu) 
{
JHtmlSidebar::addEntry(
JText::_('COM_RRRGALLERY_SUBMENU_GALLERIES'),
'index.php?option=com_rrrgallery',
$submenu == 'galleries'
);
JHtmlSidebar::addEntry(
JText::_('COM_RRRGALLERY_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_rrrgallery',
$submenu == 'categories'
);
}
}


Pozdr
Maciek


To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.

To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.

Maciek Wołpiuk

unread,
Aug 9, 2018, 8:20:26 AM8/9/18
to joomla-de...@googlegroups.com
function display($tpl = null)
{
// Get application
$app = JFactory::getApplication();
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm    = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Set the submenu
RRRGalleryHelper::addSubmenu('galleries');
//var_dump($this->items);
// Set the toolbar
$this->addToolBar();
// Display the template
parent::display($tpl);
$this->setDocument();
}

Pozdr
Maciek

Message has been deleted

Maciek Wołpiuk

unread,
Aug 9, 2018, 8:24:56 AM8/9/18
to joomla-de...@googlegroups.com
Toolbar function wrong too.

One Title and one preferences in same time. And not "text::" - "JText::"
Pozdr
Maciek


czw., 9 sie 2018 o 14:23 Vlad Anghene <vlad.a...@gmail.com> napisał(a):
I see,
I think I understand now. Thank you very much Maciek
Reply all
Reply to author
Forward
0 new messages