Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorT2
    • CommentTimeJan 2nd 2006
     
    Happy New Year Everybody!
    Does anyone know if there's a code snippet I could incorperate into the plogger script that would display the total number of images currently in all collections of a gallery?

    Many thanks,
    T2
    •  
      CommentAuthormike
    • CommentTimeJan 3rd 2006 edited
     
    Something like this should work (add this function to plog-functions.php):


    function plogger_count_pictures() {
    global $TABLE_PREFIX;

    $numquery = "SELECT COUNT(*) AS `num_pictures` FROM `".$TABLE_PREFIX."pictures`";

    $numresult = run_query($numquery);
    $num_pictures = mysql_result($numresult, 'num_pictures');
    return $num_pictures;
    }


    Then you can call it from wherever using:


    print plogger_count_pictures();


    or


    $ouput .= plogger_count_pictures();


    Depending on the context.
    •  
      CommentAuthorCroila
    • CommentTimeJan 4th 2006 edited
     
    Mike, thank you for giving us this code - I've just tried it, and it certainly works.

    However, I wonder if you could possibly give me some indication on the best place to call the function? Ideally I'd like to display the total just under the search box on my main photo page (http://croila.net/plogger/), but I am clueless about PHP and can't figure out whereabouts exactly in gallery.php to call the function to display it properly.

    Also, I was wondering what the difference is between using "print ..." or "$output .= ... is, please?

    If anyone could advise me, that would be great!

    Kind regards,
    Croila
    •  
      CommentAuthormike
    • CommentTimeJan 4th 2006
     
    In Plogger versions Beta 2.1 and earlier, we used $output .= "some HTML" to slowly build up a huge string of HTML. The "dot-equals" operator just means "take the contents of $output and add this text to the end". Then, usually somewhere at the end of the process, Plogger spits out the content of $output in one big splurge.

    So around line 85 of gallery.php you can see where the search box is generated.


    $output .= '
    <div id="wrapper">
    <table id="header-table" width="100%"><tr><td>'.generate_header().'</td><td style="text-align: right; vertical-align: bottom;">'.generate_jump_menu().generate_search_box().'</td></tr></table>';


    We can alter this to add you picture count like this (just an example)


    $output .= '
    <div id="wrapper">
    <table id="header-table" width="100%"><tr><td>'.generate_header().'</td><td style="text-align: right; vertical-align: bottom;">'.generate_jump_menu().generate_search_box().'</td></tr>
    <tr><td colspan="2">There are '.plogger_count_pictures().' images in this gallery</td></tr></table>';


    Notice I just added an extra table row to that structure so the image count appears below the search and jump menu. You can change that HTML output to make it look how you want.
    •  
      CommentAuthorCroila
    • CommentTimeJan 4th 2006
     
    Mike, thanks ever so much for your help here! It's very kind of you indeed.

    Regards,
    Croila
    • CommentAuthorT2
    • CommentTimeJan 6th 2006
     
    Mike,
    Thank you very much for taking the time to show how this is done. It's perfect.
    You are, dare I say it?......THE BOMB!!!

    Thanks much,
    T2