album.php navigation "Currently displaying images 1 to 30 of 34."

Hello,

I've looked all over and can't locate what I want. I want to put some page counting and image counting on the album.php page in last year's version of ZenPhoto.

It would be like:

Currently displaying images 1 to 30 of 34.

Thanks!

Comments

  • Try these:

    `/* SQL Counting Functions */

    function show_subalbum_count() {

    $sql = "SELECT COUNT(id) FROM ". prefix("albums") ." WHERE parentid <> \"NULL\"";

    $result = query($sql);

    $count = mysql_result($result, 0);

    echo $count;

    }

    function getIDforAlbum() {

    if(!in_context(ZP_ALBUM)) return false;

    global $_zp_current_album;

    return $_zp_current_album->getAlbumID();

    }

    function show_sub_count_index() {

    $id = getIDforAlbum();

    $sql = "SELECT COUNT(*) FROM ". prefix("albums") ." WHERE parentid = $id";

    $result = query($sql);

    $count = mysql_result($result, 0);

    echo $count;

    }`

    Put these in a customfunctions.php file in your theme directory, and then you should be able to call those functions wherever it suits you. I used them on my gallery (http://www.bushwoodworking.com/zenphoto). Keep in mind you need to be careful of context (i.e. album, index, image - that sort of thing.)

    You can also use the built in functions `getNumAlbums()` as well.

    Here's the footer line of code I use for all my pages to show a summary list of the stats of my site:

    `Albums: <?php $albumNumber = getNumAlbums(); echo $albumNumber ?> · SubAlbums: <?php show_subalbum_count(); ?> · Images: <?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber ?> · Comments: <?php $commentsArray = query_single_row("SELECT count(*) FROM ".prefix('comments')." WHERE inmoderation = 0"); $commentsNumber = array_shift($commentsArray); echo $commentsNumber ?>`

    Hope that helps.
  • Hello,

    Thanks!

    I copied the first part and made a file customfunctions.php and put it in the theme directory. I put this:

    <?php include("customfunctions.php"); ?>

    On my album page before the header close.

    It gives a lot of errors. I think this code is too new for the zen photo I have. I don't have sub albums. Is there some older code for earlier versions which will, on the album. php page, put the total amount of images viewing and the total images (like showing 15 of 25)?

    Thanks!
  • Nope. I wrote (or where I could borrowed) the code and it is specific for subalbum releases of zenphoto. Where I realize it's not in everybody's "plan" to move to the latest version, you should consider at least going to 1.0.8.2 as there are lots of stability and performance enhancements (even more in the SVN code).

    The major issue for subalbums releases right now is that there is no admin for subalbums in the web interface.

    But neither am I pushing you to go to a newer version just to take advantage of my code.

    Now the Albums and Images code should work just fine. Thus:

    `Albums: <?php $albumNumber = getNumAlbums(); echo $albumNumber ?>`
    and
    `Images: <?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber ?>`

    Should work OK.
Sign In or Register to comment.