Getting Album titles for same level albums

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

  • NB: put code in backticks, that prevents things like `` from being treated as HTML and messing up the post.

    `$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.
  • acrylian Administrator, Developer
    You also could use the direct way via mysql with a `like` query. Additionally you might want to try the printAlbumMenu plugin, although it does not directly what you want.
  • Denn Member
    Thanks folks. I'm still learning so it will take me a while to digest this but I'll get back to you with results or further questions.
  • Denn Member
    Hmm.. I DO have a lot to learn.

    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...
  • You would have to be in a subalbum for this to work. If you are at the first level naturally there are is no parent. Guess you need to add to the code
    `
    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();
    }
    }
    ?>
    `
  • Denn Member
    More...

    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.
    ``

    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.
  • acrylian Administrator, Developer
    You did not set the active class, you set the main css class, the active one is the 6th parameter.
    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
  • Denn Member
    Acrylian,

    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:
    ``

    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:

    `
    `
    ``

    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
  • Denn Member
    A little more testing showed that if I put it in the 4th I get the background when at the top level albums. It is up now if you want to see.

    `<?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
  • Denn Member
    A little more progress and a little more confusion.

    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?
  • acrylian Administrator, Developer
    Probably the album does not have subalbums so there is nothing passed to the foreach loop.
  • Denn Member
    Well, I don't think it was that as i was using a condition so the code was only being cold when it was at the right level. Anyway, I finally got it with a little creative use of the menu list plugin and some of what I learned from perusing it. Many thinks for the fine work in there acrylian! It has taught me a lot about php and greatly appreciate that and the kind help. The css still needs tweaking but you cna see the basics here if you are interested http://dennsantorophoto.com/fineart

    Denn
Sign In or Register to comment.