G'day
Got an odd one here and was hoping someone could help me out.
As part of the development of our school's Intranet, I've installed the Menalto Gallery. But I'm finding that the itemid parameter doesn't seem to be getting passed to the gallery correctly.
I got Gallery and the Mambo component hook installed OK.
However, the main menu item url for the gallery is:
jimmies.local.stjamescollege.qld.edu.au/index.php?option=com_gallery&Itemid=81
whereas the url for the individual albums within the gallery show up as (eg)
jimmies.local.stjamescollege.qld.edu.au/index.php?set_albumName=album01&option=com_gallery&Itemid=55&include=view_album.php
Unfortunately itemid=55 defines the menu item used to select one of our schools department pages. This page has a number of specialised modules and menus set to display only on this page - ie pages with itemid=55).
Anyone have any idea why the itemid value would be changing like this? How to fix it?
mambo v4.5.1a
gallery v1.4.4-pl4
Posts: 2322
Gallery only uses the itemid that Mambo gives it, so the only answer I can give is "because that's what Mambo gave us."
Itemid is only used in two places in the entire codebase - once where we retrieve the id from Mambo, and once where we generate the new URL.
The only other references to Itemid are in the SQL code that retrieves it from Mambo.
Posts: 14
I've found where the problem originates. I'm just not sure what to do to fix it.
In the file gallery/init.php there is the code:
/* For proper Mambo breadcrumb functionality, we need * to know the Item ID of the Gallery component's menu * item. +2 DB calls. <sigh> */ $db = $gallery->database{'mambo'}; $results = $db->query('SELECT id FROM ' . $gallery->database{'user_prefix'} . "components WHERE link='option=$GALLERY_MODULENAME'"); $row = $db->fetch_row($results); $componentId = $row[0]; $results = $db->query('SELECT id FROM ' . $gallery->database{'user_prefix'} . "menu WHERE componentid='$componentId'"); $row = $db->fetch_row($results); $MOS_GALLERY_PARAMS['itemid'] = $row[0]; // pick the first oneNow following through the logic, it looks up the table mos_components for a record where the field 'link' contains 'option=com_gallery' and takes the 1st field value (id) - in my case, '85'
Next it looks through the table mos_menu for a record where the field componentid is equal to the value previously retrieved - and selects the 1st instance it finds and retrieves the itemid value.
Now in my case, there are two entries in mos_menu where componentid=85 - one that defines the gallery page and one that defines the other department I mentioned. Obviously in my case, the 'wrong' one was 1st in the table and was subsequently listed.
Now I need to work out where the error lies. With mambo for duplicating the componentid value or with gallery for not selecting the 1st value (id=85) which would have been the correct value in my case.
Further research pending...
Posts: 26
Some thoughts:
Try to go into mambo's trash manager and delete any menu items in there. Gallery's mechanism for finding an itemID doesn't filter out "trashed" menu items.
There is, somewhere, another menu item (deleted or otherwise) which goes to com_gallery that has an ID of 55. Gallery's code basically just says "give me the menu/item ID of the first thing found which points to com_gallery." If you only have one, then it might be useful to delete both the one you have, and the one its getting confused with (81 and 55), nuke them from the trash manager, and then recreate both. Annoying, but it might fix the problem...
On the other hand, if you have 2 different menu items which both somehow point to the gallery component, then the existing gallery code will always find the "first" one and change its own itemID urls to use that one. This is, IMO, a flaw with how mambo and gallery interact. (Not blaming either package here...)
A possible solution if you're familier with PHP coding, would be to edit the gallery code quoted above to check for multiple row hits on the second query, and try to match the ItemID to something passed on the server request uri. This, unfortunatly, might lead to a backdoor where a person could type in url by hand, changing the itemID to the 'other' one... Not sure if this would be a concern for you.
Finally, I imagine it would be possible to install the gallery component twice, giving it a name other than com_gallery in the second install. This should also work around the issue, but I wouldn't want to try it myself. ;)
Posts: 14
It's not conflicting with a deleted item unfortunately. It's conflicting with a valid, existing menu item.
Well, not quite (if I read the logic correctly).
It says, find the id of the com_gallery component (in mos_components), THEN find the menuitem (in mos_menu) that refers to that id value and get the itemid value.
In my case, the id value assigned to com_gallery (85) shows up in two seperate menu items. One for com_gallery, the other for com_contact. I'm trying to track down a database schema to determine if the 'fault' lies with gallery's logic, or the implementation of com_contact.
Check the following SQL dumps.
Posts: 26
Wow, that's just strange, and seems like a mambo bug to me. Perhaps try to delete the "staff list" menu item, and (before nuking it from the trash manager) create a new one. THEN delete the old "staff list" from the trash manager.
The idea here would be to force mambo to give the 'staff list' a unique itemID...
(As well, I'd dump the above database info on to the mambo forums - I'm no mambo expert, but that seems like a bug...)
good luck
Gary