Member
Member
marcov   2008-07-06, 02:58
#1
In order to get around the problem described in the following post
http://www.zenphoto.org/support/topic.php?id=3383&replies=1#post-20275

my image.php uses the following paging code, instead of the printPageListWithNav function:

<?php if (hasPrevImage()) { ?> <a>" title="<?php echo gettext('Prev Image'); ?>">← <?php echo gettext(""); ?></a>

<?php if (($num = getNumImages()) > 1) { echo imageNumber() . " of " . getNumImages() . " "; }?>

<?php } if (hasNextImage()) { ?> <a>" title="<?php echo gettext('Next Image'); ?>"><?php echo gettext("");?> →</a><?php } ?>

The above code works as expected for my image page - the navigation links are not displayed if I am on the first or last page.

So, I tried to implement a similar scheme, using two custom functions I defined in a themefunctions.php file:

<?php

require_once(SERVERPATH . "/" . ZENFOLDER . "/template-functions.php");

function hasNextAlbum() { global $_zp_current_album; return $_zp_current_album->getNextAlbum(); }

function hasPrevAlbum() { global $_zp_current_album; return $_zp_current_album->getPrevAlbum(); }

?>

Next, in my index.php file I included the following:

<?php require ('themefunctions.php'); ?>

an then, where I want the paging:

<?php if (hasPrevAlbum()) { ?> <a>" title="<?php echo gettext('Prev Album'); ?>">← <?php echo gettext(""); ?></a>

<?php if (($num = getNumAlbums()) > 1) { echo albumNumber() . " of " . getNumAlbums() . " "; }?>

<?php } if (hasNextAlbum()) { ?> <a>" title="<?php echo gettext('Next Album'); ?>"><?php echo gettext("");?> →</a><?php } ?>

Now, I am not a PHP coder, so I need a bit of help trying to figure out how to fix the following errors:

Fatal error: Call to a member function getPrevAlbum() on a non-object in C:\wamp\www\zenphoto\themes\boxedblack\themefunctions.php on line 9

If I modify the themefunctions.php file to surround my functions with:

...
class themeFunctions {
... my custom functions go here
}

I get the following:

Fatal error: Call to undefined function hasPrevAlbum() in C:\wamp\www\zenphoto\themes\boxedblack\index.php on line 61
Administrator
Administrator
acrylian   2008-07-06, 16:42
#2
`hasPrevAlbum()` is a class mathod, you have to call it `$_zp_current_album->hasPrevAlbum()`
Alternativly you could use functions from templage-functions.php:
http://www.zenphoto.org/documentation/zenphoto/_template-functions.php.html#functiongetPrevAlbum
http://www.zenphoto.org/documentation/zenphoto/_template-functions.php.html#functiongetNextAlbum
Member
Member
marcov   2008-07-06, 17:17
#3
Shoot, that should have been so obvious - it`s in the function definition!

Beginner errors. Still, it did not work. I`m giving up, for now.
Administrator
Administrator
acrylian   2008-07-06, 17:38
#4
`$_zp_current_album`, a global variable, is only available if there is a "current album". For example this is the case on album.php (the thumbnail view) or on image.php (single image view).
Member
Member
marcov   2008-07-07, 03:05
#5
I see, that`s why it keeps failing for the index.php. I`ll try it for the album.php.
Thanks for the info.
Administrator
Administrator
acrylian   2008-07-07, 09:11
#6
You might want to look at our functions guide, we have also functions like `getNextPageURL` and `getNextPageURL` you could use for that.
Member
Member
marcov   2008-07-07, 13:30
#7
Yes, I did check the functions guide, I need to study it some more.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.