Parent album folder name

Hello,

I have this set up where there are parent albums, like Golf and Recreational Centers, and then there's sub albums inside that of different projects under that parent album.

On the image.php I've added a list of all the main albums, not the sub albums, and what I'd like is to create a body class based on the parent albums folder name so that I can style the links to the different albums and indicate the current parent album.

I've looked high and low and can't find something.

This outputs in the complete parent and subfolder, but I just want the parent folder name:`<?php $album = $_zp_current_album->getFolder();?>`

Thanks!!!

Comments

  • acrylian Administrator, Developer
    You could extract that from the folder of your current album. The folder names follow this parentfolder/subfolder/.... Try using `explode()` (see a PHP manual for details) to extract the parent folder. I did it partly that way in print_album_menu.php for the subalbums, you might take a look at the code there, too.
  • Thanks for the quick response. I don't know anything about php, just an artist here. I was hoping for something like (which doesn't work of course):

    `<?php $album = $_zp_parent_album->getFolder();?>`

    or `<?php getParentid();?>`

    No big deal. Would be cool though.
  • trisweb Administrator
    The Album class has a getParent method just for that.

    When in doubt, check the docs :)http://www.zenphoto.org/documentation/zenphoto/Album.html#methodgetParent

    `<?php <br />
    $parent = $_zp_current_album->getParent();

    $path = $parent->name;

    $folder = array_pop(split('/', $path));

    ?>`
  • I pasted this into my image.php and it doesn't return an error, but it also doesn't print or show anything at all:

    `<?php<br />
    $parent = $_zp_current_album->getParent();

    $path = $parent->name;

    $folder = array_pop(split('/', $path));

    ?>`

    Nice to see you again! I hope you are doing well.
  • Well, you sort of have to make it print something. You could add `echo $folder;` if you want it to show up.
  • THANKS!

    That rocks!
Sign In or Register to comment.