I've set up my component which has one view and several layouts. For each layout I've added a
views/myview/tmpl/layoutname.xml file which sets the layout via a hidden variable, like so:
<field name="layout" type="hidden" default="mylayout"/>
I'm then able to create a menu item using this component as a menu item type. It has a link in the format
I'm able to reach the layout via the SEF menu item alias.
I want to use JRoute to get the SEF URL based on the link, but when I try
JRoute::_('index.php?option=com_mycomponent&view=myview&layout=mylayout'), it just gives me the same link back and not the SEF URL.
Is what I'm wanting to do possible and if so, how?
EDIT: The solution was to add a router to my component based on the new Joomla\CMS\Component\Router\RouterBase class. I've got it working, but I'm not sure how I've got it working. When I'm able to delve into this, I'll write up a detailed solution as the answer.