Pages (2): 1 2   
Member
Member
gregluk   2008-02-27, 12:49
#1
Hi to all.
I made my own theme, and now i want to show the total number of the images i have in different albums. I'd like to have it on the index.php page of my template.
I noticed that if i use the getTotalImagesIn function without parameters it didn't work.
I'm pretty ignorant in php Sad
I tried this but it dont work
<php? $number = getTotalImagesIn(); if ($number > 1) $number .= " photos"; else $number .=" photo"; echo$number; ?>

Any help???

Thanks in advance
Administrator
Administrator
acrylian   2008-02-27, 16:23
#2
Try getNumImages() instead of getTotalImagesIn().
Member
Member
gregluk   2008-02-27, 20:46
#3
alredy tried. It seems wherever I insert getNumImages() or getTotalImagesIn() functions in the index.php page it simply block the page.
It seems to work on my album.php page instead.
I wonder why.. Missing parameters?
If u want to take a look my ZP gallery is in filmposter.netsons.org/zenphoto/index.php
Administrator
Administrator
acrylian   2008-02-27, 21:29
#4
You need to place getNumImage() within the albums loop that starts with `<?php while (next_album()): ?>` since it returns only the images of one album. getTotalimages instead returns the number of images in an album and all of it's subalbums.
Please take a look at our functions guide, too.

If you mean the total number of all images in all albums? There is no function for that if I recall correctly. Use something like this:
`<?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber ?>`(taken from stopdesign theme).

Probably worth considering a standard function for that.
Member
Member
jsumners   2008-02-27, 21:48
#5
From class-gallery.php:

`

224 /**

225 * Returns the number of images from a database SELECT count(*)

226 * Ideally one should call garbageCollect() before to make sure the database is current.

227 * @return int

228 */

229 function getNumImages() {

230 $result = query_single_row("SELECT count(*) FROM ".prefix('images'));

231 return array_shift($result);

232 }

`
Administrator
Administrator
acrylian   2008-02-27, 21:56
#6
Oh, right, there it is... To make it complete, gregluk, use it this way `<?php echo $_zp_gallery->getNumImages(); ?>`
Member
Member
gregluk   2008-02-27, 22:41
#7
Thanks a lot. Now i'll give a try to your tips. Indeed i'm looking for a function that returns total numbers of images in the whole gallery, as shown in the gallery stats on the admin page. There it works, i hoped there was something similare for the templates.
If u look at my pages, u'll find that i did 26 albums (A, B, C, etc.) to make a gallery browsable by the starting letter of an image's name. So a function that returns total numbers of images in all allbums would be nice for me.

Thanks a lot and please excuse my english, I'm from Italy Wink
Junior Member
Junior Member
selim   2008-03-17, 19:05
#8
also you can use <?php echo getTotalImagesIn($_zp_current_album);?> for total images in sub albums.
Member
Member
MelodyNelson   2008-06-05, 03:03
#9
hi,

I'm looking for a function like getNumImages() but I would like to exclude images from unpublished albums, is it possible ?

in my template, I use this code

[code]
<?php $photosArray = query_single_row("SELECT count(*) FROM ".prefix('images')); $photosNumber = array_shift($photosArray); echo $photosNumber ?>
[/code]

I have a lot of unpublished albums (images and docs used in a CMS, files are shared between the CMS and ZP). Around 60% of images are in unpublished albums (± 2500 images)

thanks

ps: sorry for my english, I'm french
Administrator
Administrator
acrylian   2008-06-05, 09:13
#10
I haven't tried yet, but if you are logged in there are no "unpublished" albums/images. The admin sees them all.

Actually `getNumImages()` gets only the image count of the current selected album.
You could try instead using the gallery class method `$_zp_gallery->getNumImages()` that gets the count of all images of your gallery.
Member
Member
MelodyNelson   2008-06-05, 15:34
#11
thanks acrylian

I've tried but the count is the same with `$_zp_gallery->getNumImages()`
I tried to see with orther browsers, clean all cookies, history, etc... but I have the total of images (published and unpublished albums)
I don't know if the problem is coming from my computer or not, you can see my gallery (still under construction) here :
http://www.bilin-village.org/photos/
Member
Member
macalter   2008-06-05, 16:36
#12
gregluk: WOW Love the site even if I can't read the words Smile What PHP function did you use to add "subtitles" to the thumbnails (album.php page)?
Administrator
Administrator
acrylian   2008-06-05, 16:44
#13
What is the number of images you have? I see a count of 4816 .
Member
Member
MelodyNelson   2008-06-05, 16:52
#14
1813 images in 18 published albums ... and 4816 in all abums
Administrator
Administrator
acrylian   2008-06-05, 16:58
#15
Ok, we found out that this function does indeed not care about published or not. We will have a fix in one of the next nigthlies.
Member
Member
MelodyNelson   2008-06-05, 17:14
#16
ok thanks, I'll check it... and thanks for zenphoto, really nice "tool"... I could manage to include albums and recent images in other pages from my website (powered by Plume CMS)

- a happy new user
Member
Member
sbillard   2008-06-05, 19:45
#17
Tonight's nightly build will allow you to pass a parameter `$gallery->getNumImages(true)` to return the count of only published images. Likewise `$gallery->getNumAlbums(true, true)` for published albums.
Member
Member
gregluk   2008-06-06, 00:36
#18
Please "pardonnez moi" OT..
Hi macalter, thanks for your good words. That was a site I did a lot time ago. I programmed to translate it into english but i never did it...
To make subtitles to image thumbnails I symply made a div beneath the div with the thumbnail with <?php printImageTitle();?> in it. A little adjustament by CSS and it worked very fine
Member
Member
MelodyNelson   2008-06-06, 16:22
#19
hi,

I've updated my ZP install with the latest nighly version (5/06) and tried `$gallery->getNumImages(true)` but the count is still the total of all images (I'm not logged on the gallery)... must I uncheck "visible" for images in unpublished albums ?

Gallery (http://www.bilin-village.org/photos/) :
- albums : 18 - 1806 images
- total images : 4752

Admin Tool (Gallery Stats)
- 4752 images (2884 unpublished)
- 39 albums (18 unpublished)
Administrator
Administrator
acrylian   2008-06-06, 16:41
#20
It's working for me with the latest svn 1679, please try tonight's nightly again.
Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.