Page 1 of 7 123 ... LastLast
Results 1 to 10 of 62
  1. #1
    Pligg Donor AnAlienHolakres3's Avatar
    Joined
    Jul 2007
    Posts
    116

    Link Clicks-Count Addon

    Hello people. This is tutorial for Link Clicks Add-on which is independent on votes and it is not its replacement. The idea is pretty simple - if user clicks on link, then click value for this specific link is increased.

    Where is clicks value shown? It depends on you but i did to be above of votes count so result looks like this:



    You can also see demo (version 0.98) on:
    Version 098

    And version 0.97 (which is highly customized) on
    Version 097 (Customized)

    Requirements
    - Pligg v 9.7 or 9.8
    - Basic PHP,css knowledge
    - voting option:1 (default ->NO star voting)
    - title as link
    -yget template

    It is neccesary to use story title as link and open story title in new window. To do that, go to your admin panel-configure Pligg-Story and set both "use story titles as link" and "open story title in new window" to true.

    Files:

    Place to your templates/yget/images folder


    Steps to do:
    AA) Go to your phpMyAdmin and run following sql:
    Code:
    ALTER TABLE your_site_links ADD COLUMN clicks bigint default 1
    A)open link.php in your libs folder and do following:
    1)add var clicks:
    var $clicks=0;

    2) after function store_basic add following function:
    PHP Code:
         //***************************************
         //function storeClicks() save click value
         //***************************************
         
    function store_clicks(){
         global 
    $db;
          
    $clicks=$this->clicks+1;
           
    $sql "UPDATE " table_links " set `clicks`=$clicks WHERE link_id=".$this->id;
            
    $db->query($sql);
         } 
    3) find function read($usecache = TRUE) and if ($link) statement. After that add this:
    PHP Code:
    $this->clicks=$link->clicks//clicks addon 

    4) find function read_basic() and update query:
    PHP Code:
    if(($link $db->get_row("SELECT link_comments, link_author, link_status, link_randkey, link_category, link_date, link_votes, link_karma, link_published_date,clicks FROM " table_links " WHERE link_id = $id"))) 
    So dont forget to add clicks column. After that add this into condition:¨
    PHP Code:
     $this->clicks=$link->clicks;               //clicks addon 
    5) find function fill_smarty($smarty, $type='full') and in this function find "viewtype". After this line add:
    PHP Code:
    $smarty->assign('link_clicks',$this->clicks);//link clicks addon 
    Thats all in this file.

    B) create a new file in your main folder and name it click_link_count.php. Add following code:
    PHP Code:
    <?php
    // The source code packaged with this file is Free Software, Copyright (C) 2005 by
    // Ricardo Galli <gallir at uib dot es>.
    // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
    // You can get copies of the licenses here:
    //         [url=http://www.affero.org/oagpl.html]affero.org: affero general public license[/url]
    //  @author AnAlienHolakres3
       
        
    if($_POST['link_id']){
                     
        include_once(
    'Smarty.class.php');
        
    $main_smarty = new Smarty;

        include(
    'config.php');
        include(
    mnminclude.'link.php');
        include(
    mnminclude.'html1.php');
        include(
    mnminclude.'smartyvariables.php');
         
        
    $link = new Link;
        
    //initialize Link and set ID
        
    $link->id=$_POST['link_id'];
        
    //read Link information
        
    $link->read_basic();
        
        
    $value $_POST['value'];        
        
    //save new clicks value
        
    $link->store_clicks(); 
       }

        
        

    ?>
    You can save it.

    C)Open xmlhttp.php in your js folder. We need to add some javascript function,so before vote function add this:
    Code:
    function sendClickedValue(link_id,htmlid) {
        var value;                                      
        
       if(document.all){
        value=parseInt(document.getElementById('click_count-'+link_id).innerText)+1;
          document.getElementById('click_count-'+link_id).innerText=value;
         
         } else {
              value=parseInt(document.getElementById('click_count-'+link_id).textContent)+1;
               document.getElementById('click_count-'+link_id).textContent=value;  
              }
    
        url = "<?php echo $my_base_url.$my_pligg_base; ?>/click_link_count.php";
            mycontent = "link_id=" + link_id;
            
             mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
             
             if (mnmxmlhttp) {   
              mnmxmlhttp[htmlid].open ("POST", url, true);
               mnmxmlhttp[htmlid].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');    
                mnmxmlhttp[htmlid].send (mycontent);
                            
              }  
      }
    Ok you can save it

    D)Open link_summary.tpl in your templates/template/ folder.
    1)after {if $Voting_Method eq 1} in the beginning add this code:

    PHP Code:
            <div class="click_count"  id="click_count-{$link_id}" >{$link_clicks}</div
    2)find {if $use_title_as_link eq true} and after {if $url_short neq "http://" && $url_short neq "://"} add into <a > element this code:
    PHP Code:
    onclick="sendClickedValue({$link_id},{$link_shakebox_index});" 
    Save.

    E) open your main.css in your templates/template/css folder
    Please note that this you should customize to your own needs.Add this class:
    Code:
    .click_count{font-size:7pt;width:54px;text-align:center;color:white;font-weight:bold;position:relative;z-index:1}
    F) Final step
    We made some customization in link_summary.tpl,remember? The little problem is that javascript used when voting replace our code and in some browsers (for example Opera) votebox is completely distorted. To avoid this we need to make one more customization:
    open xmlhttp.php in your js folder and find function changemnmvalues (id, value, error).
    Then, replace original code:
    Code:
    target1.innerHTML = b[0];
    with:
    Code:
    if(document.all){
        value=parseInt(document.getElementById('xvotes-' + id).innerText)+1;
          document.getElementById('xvotes-' + id).innerText=value;
         
         } else {
              value=parseInt(document.getElementById('xvotes-' + id).textContent)+1;
               document.getElementById('xvotes-' + id).textContent=value;  
              }
    You can save it.

    G) The core of this is done but current votebox image is not suitable for our purposes.

    Open main.css in your templates/yget folder and do following:
    1) find .news-upcoming and change vote.png to vote2.png
    2) add following class:
    Code:
    .click_count{font-size:7pt;width:54px;text-align:center;color:white;font-weight:bold;position:relative;z-index:1}
    3)find .vote-publish a and
    change line-height to 55px

    4) add class:
    Code:
    .vote {
      margin-top:-7px
    }
    Now we are going to handle "upcoming" section:
    1) find .news-upcoming2 and change vote-l.png to vote-l2.png

    This is not absolutely clean so feel free to customize it
    Thats all. Hope it works for you

  2. #2
    Constant Pligger Andtony's Avatar
    Joined
    Feb 2007
    Posts
    226
    Thanks for this. Is this method better than Ozo's one which is discussed on this thread:
    http://forums.pligg.com/pligg-mods/6...ead-votes.html

  3. #3
    Senior Member not2serious's Avatar
    Joined
    Apr 2007
    Posts
    229
    I there a way to use this is voting method 2 (5 stars). Say, post the view total with the voting statistics?

    Posted by USER 11 days ago - Average Rating: 4.5 with 6 vote(s) and 25 view(s) (Art or Editorial Post)

  4. #4
    New Pligger DvDongeren's Avatar
    Joined
    Oct 2007
    Posts
    1
    Great addon! I'll be adding this first thing in the morning, thanks!

  5. #5
    Pligg Donor AnAlienHolakres3's Avatar
    Joined
    Jul 2007
    Posts
    116

    Which method is better

    Quote Originally Posted by Andtony View Post
    Thanks for this. Is this method better than Ozo's one which is discussed on this thread:
    http://forums.pligg.com/pligg-mods/6...ead-votes.html
    Ozo´s method is great but with certain drawback - "views" value is increased after reloading page, this method increase value immediately after clicking on link.

  6. #6
    Pligg Donor AnAlienHolakres3's Avatar
    Joined
    Jul 2007
    Posts
    116

    Implementation with Star voting method

    Quote Originally Posted by not2serious View Post
    I there a way to use this is voting method 2 (5 stars). Say, post the view total with the voting statistics?
    I think so. Of course you will have to change link_summary.tpl in a little different way but the core of this is the same. Try to customize steps D and E . If you got difficulties with implementation feel free to post the problem.

  7. #7
    Senior Member not2serious's Avatar
    Joined
    Apr 2007
    Posts
    229
    I will give this a try the next time I upgrade.

    Thanks for the add on.

  8. #8
    Casual Pligger timofsuburbia's Avatar
    Joined
    Jan 2007
    Posts
    46
    Quote Originally Posted by AnAlienHolakres3 View Post
    Ozo´s method is great but with certain drawback - "views" value is increased after reloading page, this method increase value immediately after clicking on link.
    Even better, after editing the post, you don't lose the click count. See my implementation here: Pandora Stations

    I just finished converting from Ozo's version to this one.

  9. #9
    Pligg Donor AnAlienHolakres3's Avatar
    Joined
    Jul 2007
    Posts
    116
    Quote Originally Posted by timofsuburbia View Post
    Even better, after editing the post, you don't lose the click count. See my implementation here: Pandora Stations

    I just finished converting from Ozo's version to this one.
    Nice site

  10. #10
    Casual Pligger netwb's Avatar
    Joined
    Dec 2006
    Posts
    86
    you have the zip file to Link Clicks-Count Addon? and you have the source of your placement the add gooogle pub display in you pligg.tpl
    thank you very mutch "AnAlienHolakres3's Avatar
    AnAlienHolakres"

Page 1 of 7 123 ... LastLast

Similar Threads

  1. Submit Antispam Addon v 0.1
    By AnAlienHolakres3 in forum Free Modules
    Replies: 45
    Last Post: 12-04-2011, 08:48 PM
  2. Sig, link, and post count restrictions
    By Cuilan in forum Questions & Comments
    Replies: 4
    Last Post: 02-09-2009, 12:16 PM
  3. [mod] count clicks instead of votes
    By abcdefgary in forum Questions & Comments
    Replies: 6
    Last Post: 06-14-2008, 08:34 PM
  4. Vote count and Title Link only on front page
    By tommy818 in forum Questions & Comments
    Replies: 1
    Last Post: 10-25-2007, 01:40 AM
  5. I could use your clicks
    By Yankidank in forum Questions & Comments
    Replies: 1
    Last Post: 07-15-2007, 10:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting