Not signed in (Sign In)

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

    • CommentAuthortbk
    • CommentTimeNov 25th 2009 edited
     
    So after a bunch of looking around and doing some custom work of my own I have been able to add hit counts to my plogger. example: http://www.texanmom.com

    Adding hitcounts to your plogger. Open the documents listed below and look for the section of code called "EXISTING LINES OF CODE" (as shown below). Then simple copy and paste the "NEW LINES OF CODE" right below the section you just found. It should all be one continuous section of code.


    1) Add 'hits' column to your mysql database, specifically the "plogger_pictures" table. Set the default to "2" unless you don't mind it saying "1 views".
    2) Add the following lines of code to the top of the pictures.php (this document is located in the themes section) These lines will pull the current hits from the database and add another count to it.
    -----EXISTING LINES OF CODE-----

    // Find thumbnail width/height
    $thumb_info = plogger_get_thumbnail_info();
    $thumb_width = $thumb_info['width']; // The width of the image. It is integer data type.
    $thumb_height = $thumb_info['height']; // The height of the image. It is an integer data type.

    -----NEW LINES OF CODE-----

    // display hit counts for selected picture
    $hit_id = plogger_get_picture_id();
    $new_hits = 1;
    if (!isset($_SESSION['hit_id'][$hit_id])) {
    $result = run_query("SELECT `hits` FROM `plogger_pictures` WHERE `id`=$hit_id");
    if ( mysql_num_rows($result) ) {
    $row = mysql_fetch_array($result);
    $old_hits = $row['hits'];
    //update hits
    $new_hits = $old_hits + 1;
    }
    run_query("UPDATE `plogger_pictures` SET `hits`=$new_hits WHERE `id`=$hit_id");
    $_SESSION['hit_id'][$hit_id] = true;
    }
    $result = run_query("SELECT `hits` FROM `plogger_pictures` WHERE `id`=$hit_id");
    if ( mysql_num_rows($result) ) {
    $row_new = mysql_fetch_array($result);
    $n_hits = $row_new['hits'];
    }


    3) Add the following line of code to the middle of pictures.php (this document is located in the themes section). This line of code will display the new hits below the picture.
    -----EXISTING LINES OF CODE-----

    <div id="picture-holder">
    <a accesskey="v" href="<?php echo plogger_get_source_picture_url(); ?>"><img class="photos-large" src="<?php echo plogger_get_picture_thumb(THUMB_LARGE); ?>" width="<?php echo $thumb_width; ?>" height="<?php echo $thumb_height; ?>" title="<?php echo plogger_get_picture_caption('clean'); ?>" alt="<?php echo plogger_get_picture_caption('clean'); ?>" /></a>

    -----NEW LINES OF CODE-----

    <br><?php print '<b>'.$n_hits.' views</b>'?></br>


    4) Add the following line of code to the top of album.php (this document is located in the themes section). This line of code will pull the current hits from the database.
    -----EXISTING LINES OF CODE-----

    <?php while(plogger_has_pictures()) : plogger_load_picture();
    // Find thumbnail width/height
    $thumb_info = plogger_get_thumbnail_info();
    $thumb_width = $thumb_info['width']; // The width of the image. It is integer data type.
    $thumb_height = $thumb_info['height']; // The height of the image. It is an integer data type.
    $div_width = $thumb_width + 30; // Account for padding/border width
    $div_height = $thumb_height + 75; // Account for padding/border width

    -----NEW LINES OF CODE-----

    // Display number of times pictures viewed
    $hit_id = plogger_get_picture_id();
    $result = run_query("SELECT `hits` FROM `plogger_pictures` WHERE `id`=$hit_id");
    if ( mysql_num_rows($result) ) {
    $row = mysql_fetch_array($result);
    $n_hits = $row['hits'];
    }


    5) Add the following line of code to the middle of album.php (this document is located in the themes section). This line of code will display the new hits below the thumbnail.
    -----EXISTING LINES OF CODE-----

    <a href="<?php echo plogger_get_picture_url(); ?>"><?php echo $imgtag; ?></a><br />
    <span><?php echo plogger_get_picture_caption(); ?> <?php echo plogger_download_checkbox(plogger_get_picture_id()); ?></span>

    -----NEW LINES OF CODE-----

    <br><?php print ''.$n_hits.' views'; ?></br>



    For those of you who are lazy and don't want to edit code you can downloaded the edited files here. You will still have to edit your MySQL table plogger_pictures though to include the 'hits' column.
  1.  
    This post is very helpful. Thanks for making an effort to put this here and share it to noobs like me. beating the casino