The simpler media website CMS
I have a site with travel stories and the basic structure is somewhat like this:
Gallery
-Trip1
--Day1
--Day2
--Day3
-Trip2
--Day1
---Beach
---Mountain
--Day2
...etc.
My goal is to form a menu menu for the current branch. I.e top level parent for the current album and all of its children. E.g. if I'm in the Mountain album, the branch menu should show:
-Trip3
--Day1
---Beach
---Mountain
--Day2
I can get the current branch menu with this:
$parents = getParentAlbums();
if (count($parents)==0) { // if we are at the top level album
$top_parent = $_zp_current_album;
} else {
$top_parent = $parents[0];
}
$branch_menu = getAllAlbums($top_parent); // get all decendent albums
array_unshift($branch_menu, $top_parent->name); // prepend with the top level album
My next step is to create some kind of nav list for my Bootstrap implementation. I've experimented with printAlbumMenuListAlbum function, but the output is not exactly what I would prefer. I'm considering to copy this function and modify it to meet my needs.
Does this all make sense or would there be a better approach for what I'm trying to achieve?
Comments
I can understand that the print_album_menu plugin may not fit with default html (although you can do wonders with CSS). It's on the long list to make this more flexible.
An alternative could be the menu_manager but that is primarily for manual custom menus, although it can work with function calls, too. But that might be more complicated.
If you just want the direct subalbums you should look at the core object model framework. Here some basic code for getting the direct subalbums of an album:
$subalbums = $_zp_current_album->getAlbums(0); // 0 means no pagination
Within a subalbum you can get the parent using:
$parent = $_zp_current_album->getParent();
Then you can get the subalbums again using:
$subalbums = $parent->getAlbums(0);
Here is general tutorial about the object model as you then need to create album objects to use.
https://www.zenphoto.org/news/zenphotos-object-model-framework/
Thanks for the reply. It sounds like my approach is not too bad. With what I have, I get the full list of all subalbums:
I actually want to always show the entire branch menu. E.g. all albums from the Trip2 from my example. No matter where I am within that branch; either at the top parent or any of the subalbums.
It also sounds like that it might be easiest for me to make a copy and modify the printAlbumMenuListAlbum function as I think in this case it will be easier for me than trying to do all the CSS magic.
I'll keep my eye on possible updates on the print_album_menu plugin. Keep up the good work!
Sure, that might be the best for your purpose then.