Getting the current image number in a collection
  • I'm trying to grab the number of the current image displaying in a collection so that it will display something like "2/40"

    So far I have something like this:



    <v:a path="prev()" id="photoPrev" class="fade"><img src="/images/arrowLeft.jpg" alt="<" /></v:a>
    <span id="pageWrapper"></span> / <v?=verb("../gallery")->totalMatches()?>
    <v:a path="next()" id="photoNext" class="fade"><img src="/images/arrowRight.jpg" alt=">" /></v:a>



    Generating this:

    <- /272 ->

  • 1 Answer sorted by
  • Hey --

    I don't see a good way to do this without writing some PHP code. Maybe something like:


    function get_index($path) {
    $i = 0;
    foreach (vae($path) as $r) {
    if ($r->id == $_REQUEST['id']) {
    return $i;
    }
    $i++;
    }
    }

    ...

    <v?=get_index("../gallery")?>

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion