Count images...

vallu

Joined: 2009-06-04
Posts: 25
Posted: Sun, 2009-07-26 13:36

Is it possible to count and display how many images are in the current album?
With this code I can count all images in my Gallery:
<?= t("Images: %count", array("count" => ORM::factory("item")->where("type", "photo")->count_all())) ?>

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2009-07-26 16:50

Why do all that. Just take a look at gallery3/themes/default/view/pager.html.php

The information is already there.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
vallu

Joined: 2009-06-04
Posts: 25
Posted: Sun, 2009-07-26 17:56

Thanks for reply. You mean this code:

  <? /* @todo This message isn't easily localizable */
     $from_to_msg = t2("Photo %from_number /%count",
                       "Photos %from_number-%to_number /%count",
                       $total_items,
                       array("from_number" => $current_first_item,
                             "to_number" => $current_last_item,
                             "count" => $total_items)) ?>

  <li><?= $from_to_msg ?></li>

But what I have to change to use this at gallery3/themes/default/view/header.html.php
Now I only get "Photos - /"

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Sun, 2009-07-26 18:04
vallu wrote:
Is it possible to count and display how many images are in the current album?
With this code I can count all images in my Gallery:
<?= t("Images: %count", array("count" => ORM::factory("item")->where("type", "photo")->count_all())) ?>

You need to specify the album id. Something like:
<?= t("Images: %count", array("count" => ORM::factory("item")->where("type", "photo")->where("parent_id", $item->id)->count_all())) ?>

Where $item->id is the ID# of the album.

 
vallu

Joined: 2009-06-04
Posts: 25
Posted: Sun, 2009-07-26 19:39
rWatcher wrote:
You need to specify the album id. Something like:
<?= t("Images: %count", array("count" => ORM::factory("item")->where("type", "photo")->where("parent_id", $item->id)->count_all())) ?>
Where $item->id is the ID# of the album.

Thank you, that is what I'm looking for! Works fine for me.