zenphoto forums » Usage Support

Level of album hierarchy

(5 posts)
  • Started 2 weeks ago by imagepet
  • Latest reply from imagepet
  1. imagepet

    Member
    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 2 weeks ago #
  2. sbillard

    Contributor
    Joined: May '07
    Posts: 10,507

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

    Posted 2 weeks ago #
  3. imagepet

    Member
    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 2 weeks ago #
  4. Zenphoto development team
    fretzl

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

    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 2 weeks ago #
  5. imagepet

    Member
    Joined: Aug '16
    Posts: 13

    Hi fretzl,

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

    Posted 2 weeks ago #

RSS feed for this topic

Reply

You must log in to post.