Multiple menu items workaround (Joomla 3.0)

Phoca Gallery - image gallery extension
NL8
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 13 Jan 2013, 22:37

Multiple menu items workaround (Joomla 3.0)

Post by NL8 »

Situation: Joomla 3.0. Phocagalllery working great! Two gallery categories: Photos and Videos, each with their own categories. Two menu items: Photos and Videos.

When user clicks on Videos, the video categories are displayed. Great. PROBLEM: the links of those (video) categories refer to the photos menu item:
http://<site>/photos/category/4-video-2012

The result: when user clicks on this category, the category (4-video-2012) is displayed, but now the menu item Photos is active!..

The problem seems to be as follows: the link is built in
/components/com_phocagallery/views/categories/view.feed.php (line 91)
This calls function getCategoryRoute, found in
/administrator/components/com_phocagallery/libraries/phocagallery/path/route.php
It sets needles to category -> catid and categories. The last one is what we're looking for.

The function _findItem (same file) goes through all phocagallery menu items (here: 2) and if the view is right (categories) and id in query (empty) is same as id we look for (also empty.. so yes they are the same), it returns this menu item.

As the first menu item (Photos) is a match, it returns this as the (wrong) result.

Best fix would be to check if the subcategory is subcategory (or subsub or ..) of the menu item. For the time being, I came up with a quick fix, which seems to be working.

The fix is to check whether the menu item we are looking for, has the same ID as the active menu item.

Function _findItem:
// existing code
$menus = &JApplication::getMenu('site', array());
$items = $menus->getItems('component', 'com_phocagallery');
// new code
$active_item =& $menus->getActive();
$active_menuitemid = $active_item->id;
few lines below:
// old code:
if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) {
// new code:
if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id) && (@$item->id == $active_menuitemid)) {

May be there's a much simpler solution?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49144
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Multiple menu items workaround (Joomla 3.0)

Post by Jan »

Hi, the problem is, sometimes (in some cases) you are e.g. located in category view but the active menu item is categories view - and because of tree you need to have set the active menu item to categories view - because you can navigate through all the tree - from categories to category to detail and back and allways you need to have stored the menu link e.g. to categories even you are located in detail view ... so for now not sure if your sulition does not break any other needed features. I will take a look at it and will do more tests.

Thank you.
Jan
If you find Phoca extensions useful, please support the project
Kon
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 22 Oct 2014, 10:29

Re: Multiple menu items workaround (Joomla 3.0)

Post by Kon »

This solution worked great for me Nl8. A little bit late response but thnk you very much. Being tring to solve this out some days now. Thnks again.
Post Reply