Hi,
My first post here and I've been searching for a while with no luck on this topic. What I want to do is get the titles of all the albums at the same level as a parent album from one gallery when I go into the gallery album's subalbums. For example:
Gallery: Fine Art
Albums: Abstract, Architecture, Places
When I go into any of those albums' subalbums (e.g. Abstract | Light Floats) I want to be able to show links to Abstract, Architecture, Places.
Getalbumtitle() only gets the other subalbum titles so doing something like this:
`
<?php while (next_album()): ?>
" title="View album: <?php echo getAlbumTitle();?>"><?php echo getAlbumTitle();?><?php endwhile; ?>
`
Only gets me the nav for the subalbums. I guess what I need is something more like GetGalleryAlbumtitles() or something but I can't find any calls or combo of calls that would do it nor ways to call it before departing the gallery the subalbum is called from and passing it to the subalbum'a album.php
Any ideas or solutions?
Comments
`$parent = $_zp_current_album->getParent()` will give you the parent album for the album you are displaying. Then you would have to use code like:
`
$siblings = $parent->getSubalbums();
foreach ($siblings as $albumname) {
$album = New Album($_zp_gallery, $albumname);
...
li>" title="View album: <?php echo $album->getTitle();?>"><?php echo $album->getTitle();?>
...
}
`
NOTE: I just typed this code, I did not debug it. If the code is not quite correct at least the approach is.
Tried (starting at line 47):
`<?php $parent = $_zp_current_album->getParent();?>`
`<?php $siblings = $parent->getSubalbums();?>`
`<?php foreach ($siblings as $albumname)`
`{$album = New Album($_zp_gallery, $albumname);}?>`
`<?php echo $album->getTitle();?>`
Got - Fatal error: Call to a member function getSubalbums() on a non-object in (full path to) dennsantorophoto/fineart/themes/highslide/album.php on line 48
As I said I'm a newbie here although I've been coding in other languages (mostly OPAL and HTML/XHTML) for a couple of decades. PHP is still new to me. I'm not familiar with the exact meaning of -> for example (although I get that it basically means do the function on the right to the variable on the left).
I'm not sure where the variable $_zp_current_album is getting assigned or if it is a property of something already assigned (it doesn't seem to be listed under gallery or album . The documentation (which unfortunately doesn't seem searchable) does not seem to show it. So I'm guessing that it isn't assigned and so the call it is trying to generate to getparent() isn't returning an assignment to $Parent. But is so, then why don't I get the error on line 47 instead of 48?
I've also tried echoing the vars but get nothing in the resulting page generated.
Denn
PS: Hope that is the correct use of backticks. I'll learn...
`
if (!is_null($parent)) {
....
}
`
BTW, you do not need to open and close PHP each line.
`
<?php $parent = $_zp_current_album->getParent();
if (!is_null($parent)) {
$siblings = $parent->getSubalbums
foreach ($siblings as $albumname) {
$album = New Album($_zp_gallery, $albumname
echo $album->getTitle();
}
}
?>
`
Playing with the plugin as suggested. Mostly works as I want but I can't turn on the active CSS it seems
`<?php printAlbumMenuList("list-top",'','','',"mmhere",'',"", false);?>`
mmhere is the css class.
.mmhere {
background-color: #CCFFCC;
padding-bottom: 5px;
padding-top: 5px;
}
Looking at the generated code it just doesn't show up.
`
`
`- Abstract Work
`
- Boston ICA Series
`- Places
`
``
`
`
`
`
But it is close. I'm getting most of what I need with this. I may be continuing to play with it but you can see where I have gotten at: http://dennsantorophoto.com/fineart/ if you are interested.
But you are displaying top levelalbums with the menu on the site so you need to use the 3rd and 4th parameter.
http://www.zenphoto.org/documentation/plugins/_plugins---print_album_menu.php.html#functionprintAlbumMenu
Thanks for you help so far. Thanks to Sbillard too. I'll be looking at that code later today but I have to deliver a bunch of work to a new show this morning. Anyway...
Moving "mmhere" to the 6th position didn't seem to effect anything.
`<?php printAlbumMenuList("list-top",'','','','',"mmhere","", false);?>`
Still gets me:
`
`
`- Abstract Work
`- Boston ICA Series
`- Places
`
``
`
`
`
`
This menu displays on top level albums or subalbums (what I want it to do). It does it appropriatley with the subalbum level displaying all active links:
`
`
`- Abstract Work
`- Boston ICA Series
`- Places
`
``
`
`
`
The menu layer above that is generated in my html inserted into Album.php. The nav menus are desiged to be two layers always visible. The top is the overallsite. When you go into one of the galleries (Fine Art in this case but there are others like Performer candids) I want the user to see all the top level albums whether they are in a top level album or a subalbum. Makes the nav clean and easy to understand. But I am trying to use the mmhere class to turn on the background highlight as you see in the top level menu under fine art (still needs a bit of css tweaking to line up properly in all browsers but that is a detail for later).
Thanks again for the help. Getting closer all the time.
Denn
`<?php printAlbumMenuList("list-top",'','','mmhere','',"","", false);?>`
So that is great. I guess I have to understand better how you are defining things. But I'm getting there. Thanks again. Next to figure out when I'm in a subalbum, give it a title and still mmhere the now active link for the right parent menu in the list. Another task for later today.
Thanks again folks.
Denn
Using Sbillard's code I get "Warning: Invalid argument supplied for foreach()" but I don't see the problem with the argument. It looks to be formed correctly. Perhaps a class or typing mismatch?
Denn