Is there a function that return the number of album pages (without printing)? I am using `printPageListWithNav()` but would like to hide it if there is only one page.
Better yet, I would copy the entire printpagelistwithnav function, and put it into your custom functions file (if you have one - i can explain how to to this if you don't know how) and create your own function. theoretically it should work fine, and then you won't be hacking the core files at all. makes it a lot cleaner for upgrades later....
And depending on your needs, you may be able to modify these SQL counting functions to fit your needs. I use them for my custom album, subalbums counts on my zenphoto pages.
`/* 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";
You would create a new php file say for instance you have it in your theme folder you would insert the following code in the head where you other includes are:
In the context of this thread, a Custom Functions File would be a php file not a javascript file and as such would be included using the following at the top of index.php, album.php and image.php (in your theme folder):
Comments
`function getNumAlbums(){
global $_zp_gallery;
return count($_zp_gallery->loadAlbumNames());
}
`
Bung it in the template-functions.php somewhere and see if it works
(there are probably much better ways of doing it, but this should be a quick and dirty hack)
`/* 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;
}`
How do I create a custom functions file?
Thanks,
GS
<script src="<?php echo $_zp_themeroot ?>/custom_functions.js" type="text/javascript"></script>
```<?php /* load custom functions first<br />
@require_once("includes/custom-functions.php"); ?>`
The includes folder is within the theme folder that you wish to write custom functions for. (It's not necessary, but I like it for neatness)
`
<?php if(getTotalPages(false) > 1) { ?>
<?php printPageListWithNav("« prev", "next »"); ?>
<?php } ?>
`