Level of album hierarchy

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.

Comments

  • `count(explode('/', $albumobj->name));`
  • Unfortunately, I always get 1 as result. What's wrong?
    Hint: I'm using a customized zpmobile theme and the zenpage plugin.
  • fretzl Administrator, Developer
    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`
  • Hi fretzl,

    Works great, exactly what I was asking for. Thanks.
Sign In or Register to comment.