As JSubmenuHelper is deprecated, how to migrate to JHtmlSidebar?

by YoKoGFX   Last Updated October 15, 2019 09:10 AM

The only source I found about this is from this post: Replacing JSubmenuHelper with JHtmlSidebar / Administrative menu in Joomla 4

The issue here is that I tried it, and it doesn't show the Sidebar if I try it with JHtmlSidebar.

Here is the Code:

public function render($config = array())
{
    $config = new KObjectConfigJson($config);
    $config->append(array(
        'toolbar' => null
    ));

    foreach ($config->toolbar->getCommands() as $command)
    {
        if(!empty($command->href)) {
            $command->href = $this->getTemplate()->route($command->href);
        }

        JSubmenuHelper::addEntry($this->getObject('translator')->translate($command->label), $command->href, $command->active);

    }

    return '';
}

In this, JSubmenuHelper::addEntry should be replaced with the JHtmlSidebar function.

I tried to change the line to

JHtmlSidebar::addEntry($this->getObject('translator')->translate($command->label), $command->href, $command->active);

and to

JHtmlSidebar::render($this->getObject('translator')->translate($command->label), $command->href, $command->active);

but on with addEntry the sidebar is hidden and with render() there is no content in it.

What is wrong with the attempts that I already tried?



Related Questions


Updated March 12, 2016 07:04 AM

Updated March 14, 2017 10:10 AM

Updated March 23, 2017 10:10 AM

Updated February 19, 2019 18:10 PM

Updated August 09, 2016 08:04 AM