I've written a site-specific hack to the metadescription module. It involves putting this code in the metadescription_theme.php helper file:
} elseif ($theme->item->is_album()) {
$tagsItem = ORM::factory("tag")
->join("items_tags", "items_tags.tag_id", "tags.id")
->join("items", "items.id", "items_tags.item_id", "LEFT")
->where("items.parent_id", "=", $theme->item->id)
->order_by("tags.id", "ASC")
->find_all();
However this code causes problems in 3.0.1, Specifically it caused pages which are not album, photo or tag pages to return a white screen with very little html. I guess the code crashes when trying to output the meta tags.
This would suggest that in 3.0.1 these pages return TRUE to the question "$theme->item->is_album()" and the code then crashes because they can't have tags. At least that's my guess. Why is this?
I have rearranged the code so that it now works, but for future reference I'd like to understand this change in behaviour.
U-G
Posts: 16504
You said you rearranged the code and now it works. Could you post the entire code block of your modification both before and after the change?
____________________________________________
Like Gallery? Like the support? Donate now!
Posts: 722
If the current page isn't an item (album, photo, video) then the is_album() function doesn't exist, causing the script to crash.
Out of curiosity, what were you trying to change in metadescription? Is it anything that I should incorporate back into the main module?
Posts: 290
if (is_object($theme->item()) && $theme->item()->is_album()) {}
is_object() will return true if it's an item/album page, and false if it's anything else (reauth page, etc).
should stop it crashing.
Dan
danneh.org :: Gallery3
Posts: 693
@rWatcher - I don't think this change is of general interest. I don't use tags for albums - I regard them as being the tags for all the images in the album, if any. This is how the "About this album" module works. This approach may not work for everyone, but it works for me. So the hack is to include the code from ATA which, if the item is an album, finds all the tags of all its images.
The version of metadescription_theme.php which was working is (my insertion is the first elseif block):
but this crashed on pages other than image/album/tag pages. I rearranged the code so that in 3.0.1 the following works:
This is not a big deal. There are various ways to get this to work. My point simply is that I am still struggling to learn this php Kohana thing and I thought that I understood how $theme->item->is_album() worked. But then I discover that the first version didn't crash on 3.0 but does on 3.0.1 on "other" pages and I just wondered if something changed or whether my initial understanding was incorrect.
Still learning - that's all.
U-G