1 minute reading time (207 words)

How to use two layouts from the same view for two submenus

Have you ever came across a situation, when working on a Joomla component- you need two sub-menus to be shown in admin backend which belong to same view and different layouts?
If yes, then you must have noticed that this does not work as expected. 
Here's the solution for the same 

Suppose there are two submenus - this is the PHP code to add two submenus -

As you can see the 'view' for 2 submenus is same and 'layouts' are different
So when you browse to one of the above-mentioned views - you will see both submenus as active as shown in the image below -
TO fix this you will need to add some jquery code to not show another submenu as active.
FILE - view=reports&layout=default
//override active menu class to remove active class from other submenu
$('ul>li> a[href$=\"index.php?option=com_jgive&view=reports&layout=payouts\"]:last').removeClass('active');
FILE - view=reports&layout=payouts
//override active menu class to remove active class from other submenu
$('ul>li> a[href$=\"index.php?option=com_jgive&view=reports&layout=default\"]:last').removeClass('active');
After adding code in those two layouts you will see that only the current submenu is shown as active.

It works well on Joomla 2.5.x. :)

Jbolo 3.0 - alpha 4 - supporting group chat
Jingle Bells !! Jingle Bells !! 20% off in the Sto...

Related Posts


By accepting you will be accessing a service provided by a third-party external to https://techjoomla.com/

Blog Topics