zenphoto forums » Usage Support

Level of album hierarchy

(5 posts)
  • Started 6 months ago by imagepet
  • Latest reply from imagepet

No tags yet.

  1. imagepet

    Joined: Aug '16
    Posts: 13

    Hi everybody!

    Is there a possibility to know, on which level of the album hierarchy an album resides (album, sub album, sub sub album, ...)? I would like something like getAlbumHierarchyLevel().
    I didn't find anything in the forum nor in the documentation of the functions.
    Many thanks.

    Posted 6 months ago #
  2. sbillard

    Joined: May '07
    Posts: 10,520

    count(explode('/', $albumobj->name));

    Posted 6 months ago #
  3. imagepet

    Joined: Aug '16
    Posts: 13

    Unfortunately, I always get 1 as result. What's wrong?
    Hint: I'm using a customized zpmobile theme and the zenpage plugin.

    Posted 6 months ago #
  4. Zenphoto development team

    Zenphoto team
    Joined: Sep '08
    Posts: 1,115

    Try this:
    Put this function in your theme functions.php

    function printAlbumHierarchyLevel() {
     global $_zp_current_album;
     $albumname = $_zp_current_album->name;
     $level = substr_count($albumname, '/') + 1;
     echo "Album level: " . $level;

    (This will give you Album level: 1 for a top-level album)

    Then call <?php printAlbumHierarchyLevel(); ?> where you want it to appear in album.php and/or image.php

    Don't forget to read the Forum rules and usage resources
    Posted 6 months ago #
  5. imagepet

    Joined: Aug '16
    Posts: 13

    Hi fretzl,

    Works great, exactly what I was asking for. Thanks.

    Posted 6 months ago #

RSS feed for this topic


You must log in to post.