I've been racking my brain how to add links to all the views of my component in the shiny new Joomla4 backend; I used to do it via JSubmenuHelper, but that, apparently being deprecated also before, has now been completely removed.
I've tried what's mentioned here: How do I apply JHtmlSidebar to add a sidebar to my admin view? , i.e., in the views, I call first the addSubmenu function of the helper (which in turn uses JHtmlSidebar::addEntry), then JHtmlSidebar::render in my view.html.php (in the display method of the JViewLegacy-derived class there).
But I don't get any menu entries for my component. The "default" view shows up fine, but I don't get submenu entries or tabs to link to the other views of my component. There are no errors in the browser or in the logs; I just don't get any indication of the submenu on the left. Edit: I don't get it to run with JHtmlSidebar in J3 as well. There must be something I'm missing. Here's my code: In the view.html.php:
class mycomponentViewblocklist extends JViewLegacy
{
function display($tpl = null) {
// other stuff...
mycomponentHelper::addSubmenu('myview');
$this->addToolBar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
In helpers/mycomponent.php:
class mycomponentHelper extends JHelperContent
{
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_MYCOMPONENT_SUBMENU_MYVIEW'),
'index.php?option=com_mycomponent&view=myview',
$vName == 'myview'
);
// ...
This does not work in J3 and J4, while using JSubMenuHelper::addEntry instead of JHtmlSidebar::addEntry does work in J3. What else is required? Do I need to add something in my tmpl folder?
I can't see any obvious difference to what I'm doing in comparison to the com_banner component, which gets a nice submenu with all its four views as link entries (edit: see my answer below about the submenu; I misunderstood where that came from; but it also has a nice sidebar on the left in addition to the submenu).
For all the announcement of Joomla4, so far I have seen relatively little in terms of migration guides for J3 / J2 components, could anybody point me in some direction there maybe, if this could help the issue here?