Forums

[resolved] Heart Icon to record hits (3 posts)

  1. Dunkkan
    Member
    Posted 3 years ago #

    Hi,

    I've been searching for a plugin which can record the clicks the users do in a link (or icon), and then show the global result next to it (for example, in the excerpt or the bottom of a post).

    It would be similar to counting and output the comments in a post.

    In Last.fm they have it to rate the artists' pics. Example ;)

    Does anybody knows how could I achieve something like this ?
    Thanks.

  2. Dunkkan
    Member
    Posted 3 years ago #

    Hi guys,

    I've been searching around, and I found quite of PHP scripts out there. I'm still searching the finest one to my purpouse though.

    The following script will count page views, and output the results in the template, as seen here (not tested).

    <?php
    
    /**
     * Create an empty text file called counterlog.txt and
     * upload to the same directory as the page you want to
     * count hits for. [Note: in my current theme's folder?]
     *
     * Add this line of code on your page: [Note: anywhere in a template?]
     * <?php include "text_file_hit_counter.php"; ?>
     */
    
    // Open the file for reading
    $fp = fopen("counterlog.txt", "r");
    
    // Get the existing count
    $count = fread($fp, 1024);
    
    // Close the file
    fclose($fp);
    
    // Add 1 to the existing count
    $count = $count + 1;
    
    // Display the number of hits
    // If you don't want to display it, comment out this line
    echo "Page views:" . $count . "
    ";
    
    // Reopen the file and erase the contents
    $fp = fopen("counterlog.txt", "w");
    
    // Write the new count to the file
    fwrite($fp, $count);
    
    // Close the file
    fclose($fp);
    
    ?>

    Thanks if someone have some extra idea about that (unique hits in a link ?).

  3. Dunkkan
    Member
    Posted 3 years ago #

    Found a possible solution here : http://planetozh.com/blog/2004/09/click-counter-plugin-for-wordpress/

    and here : http://blog.ericlamb.net/projects/wp-click-track/

    The first one needs to arrange some extra columns in the database, and the second one looks great but doesn't seems to output the hits, because is intended to be statistical (admin-side).

    I'll get a look, hope that helps.

Topic Closed

This topic has been closed to new replies.

About this Topic