Member
Member
guischarf   14-12-2006, 20:55
#1

Hello,

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.

Thanks

Member
Member
Donkikong   15-12-2006, 20:15
#2

You could try this:

`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)

Member
Member
thinkdreams   15-12-2006, 21:20
#3

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....

Member
Member
thinkdreams   15-12-2006, 21:22
#4

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";

$result = query($sql);

$count = mysql_result($result, 0);

echo $count;

}`

Member
Member
guischarf   02-01-2007, 19:22
#5

Hi think dreams!

How do I create a custom functions file?

Thanks,

GS

Member
Member
aitf311   02-01-2007, 19:56
#6

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:

Member
Member
Donkikong   03-01-2007, 12:10
#7

In the context of this thread, a [b]Custom Functions File[/b] would be a php file [b]not a javascript[/b] 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):



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)
Junior Member
Junior Member
Mazer23   23-04-2009, 19:04
#8

Here is a basic fix that doesn't require you to use a custom functions file:

`

[align=center]

[/align]

`

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.