counting clicks instead of votes

Register an Account
Reply
 
Thread Tools Display Modes
  #31 (permalink)  
Old 10-25-2007, 12:02 AM
New Pligger
 
Join Date: Jan 2007
Posts: 20
Quote:
Originally Posted by ozo View Post
Hey I implemented a way to do this but I don't vouch that this is the best way to do it, but it worked for me @ Meshedlinks / Popular, you can see it in action. Follow this steps - however this requires that you have a little, just a little, technical knowledge:

1. create a field in your pligg_links table to store the number of clicks (NOTE: I guess this can be done simply by using extrafields, but I guess someone can work on this solution and have something better)
To create field in your pligg_links table execute this against your database :
ALTER TABLE pligg_links ADD COLUMN clicks BIGINT DEFAULT 1;

2. Modify link.php (in libs folder as follows):
a. add var $clicks = 1; just after var $current_user_reports = 0;
b. replace this:
$db->query("UPDATE " . table_links . " set link_summary='$link_summary', link_title_url='$link_title_url', link_url='$link_url', link_url_title='$link_url_title', link_title='$link_title', link_content='$link_content', link_tags='$link_tags', link_field1='$link_field1', link_field2='$link_field2', link_field3='$link_field3', link_field4='$link_field4', link_field5='$link_field5', link_field6='$link_field6', link_field7='$link_field7', link_field8='$link_field8', link_field9='$link_field9', link_field10='$link_field10', link_field11='$link_field11', link_field12='$link_field12', link_field13='$link_field13', link_field14='$link_field14', link_field15='$link_field15', clicks='$clicks' WHERE link_id=$this->id");
with the $db->query you have in the store function. or alternatively just include ,clicks='$clicks' after $link_field15 in the $db->query function in the store function.
c. In the read function look for if($link) and at the end of it where you have $this->link_summary = $link->link_summary; include $this->clicks = $link->clicks; just below it.
d. In read_basic function replace the $db->get_row.... by $db->get_row("SELECT 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"))) OR simply append , clicks to $db->get row just after link_published_date
e. add $this->clicks=$link->clicks; just after $this->published_date=unixtimestamp($date); still in read_basic
f. add this entry : $smarty->assign('clicks', $this->clicks); just after $smarty->assign('link_category', $this->category_name());
That is all for that file

3. Open out.php in your pliggroot directory. include this:
$db->query("UPDATE " . table_links . " SET clicks = clicks + 1 WHERE link_id = " . $id); just before header("HTTP/1.1 301 Moved Permanently");

4. open up link_summary.tpl in your templates directory and include this:
<span class="clicks">
Views : {$clicks}
</span>
where you want the clicks to be displayed. In your css fine you can define how it should look by creating an entry class clicks and defining it.

Well, that is about it. As I said this is my solution. I am certain there can be an optimized version, but this method does get things to work. Remember you can check it out at Meshedlinks / Popular

Am working on displaying and viewing links by votes. So for instance you have a tab at the top that says top links by votes or upcoming links by votes, if you get what I mean.

If you have any questions don't hesitate to post them.
I have got this module working perfectly fine...

Except, I am using the new GreyBox for my videos...
When user clicks on an image to play, "click" for that does not get counted.
I was wondering if someone can help me to get this working. Thx.
Reply With Quote
  #32 (permalink)  
Old 10-26-2007, 06:04 AM
Constant Pligger
 
Join Date: Feb 2007
Posts: 226
Quote:
Originally Posted by Partyman View Post
how its possible to sort the storys by views/clicks ???
Sorting by clicks.
I'm using 9.7 and Yget so can't be sure if this is still the same in 9.8.


Step 1.
Open libs/search.php and find this:
Code:
	function do_setmek(){
And add this after the last condition before { else }:
Code:
		} elseif ($setmek=='clicks') {
						$this->filterToTimeFrame = "";
			$this->orderBy = "clicks DESC";
You can set the time frame as you wish by adding today, yesterday, week etc. Or if you wish to have more than one tab just change the clicks to something unique for each tab.
Save.

Step 2.
Open header.tpl and find the tabs and add this:
Code:
{if $setmeka eq "clicks"}<span>Sort by clicks</span>{else}<a href="index.php?part=clicks">Sort by clicks</a>{/if}
You can change the Sort by clicks-text to what you want. If you made multiple tabs just change
the clicks and part=clicks to the name of your tab.

Hope this helps.

Last edited by Andtony; 10-26-2007 at 06:10 AM. Reason: typo
Reply With Quote
  #33 (permalink)  
Old 11-03-2007, 12:27 AM
Casual Pligger
 
Join Date: Oct 2007
Posts: 39
any idea for the Editing/Voting-Bug?
Reply With Quote
  #34 (permalink)  
Old 11-03-2007, 09:36 AM
Casual Pligger
 
Join Date: Jan 2007
Posts: 46
Quote:
Originally Posted by Partyman View Post
any idea for the Editing/Voting-Bug?
This version here http://forums.pligg.com/pligg-tutori...html#post44542 doesn't have that problem.
Reply With Quote
  #35 (permalink)  
Old 11-04-2007, 06:24 PM
Casual Pligger
 
Join Date: Oct 2007
Posts: 39
i dont want to install this new addon, i need a bugfree-version of this mod
Reply With Quote
  #36 (permalink)  
Old 11-07-2007, 11:11 PM
netwb's Avatar
Casual Pligger/Coder
Pligg Version: 1.0
Pligg Template: wistie
 
Join Date: Dec 2006
Location: Bruxelles
Posts: 86
Quote:
Originally Posted by ozo View Post
Hey I implemented a way to do this but I don't vouch that this is the best way to do it, but it worked for me @ Meshedlinks / Popular, you can see it in action. Follow this steps - however this requires that you have a little, just a little, technical knowledge:

1. create a field in your pligg_links table to store the number of clicks (NOTE: I guess this can be done simply by using extrafields, but I guess someone can work on this solution and have something better)
To create field in your pligg_links table execute this against your database :
ALTER TABLE pligg_links ADD COLUMN clicks BIGINT DEFAULT 1;

2. Modify link.php (in libs folder as follows):
a. add var $clicks = 1; just after var $current_user_reports = 0;
b. replace this:
$db->query("UPDATE " . table_links . " set link_summary='$link_summary', link_title_url='$link_title_url', link_url='$link_url', link_url_title='$link_url_title', link_title='$link_title', link_content='$link_content', link_tags='$link_tags', link_field1='$link_field1', link_field2='$link_field2', link_field3='$link_field3', link_field4='$link_field4', link_field5='$link_field5', link_field6='$link_field6', link_field7='$link_field7', link_field8='$link_field8', link_field9='$link_field9', link_field10='$link_field10', link_field11='$link_field11', link_field12='$link_field12', link_field13='$link_field13', link_field14='$link_field14', link_field15='$link_field15', clicks='$clicks' WHERE link_id=$this->id");
with the $db->query you have in the store function. or alternatively just include ,clicks='$clicks' after $link_field15 in the $db->query function in the store function.
c. In the read function look for if($link) and at the end of it where you have $this->link_summary = $link->link_summary; include $this->clicks = $link->clicks; just below it.
d. In read_basic function replace the $db->get_row.... by $db->get_row("SELECT 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"))) OR simply append , clicks to $db->get row just after link_published_date
e. add $this->clicks=$link->clicks; just after $this->published_date=unixtimestamp($date); still in read_basic
f. add this entry : $smarty->assign('clicks', $this->clicks); just after $smarty->assign('link_category', $this->category_name());
That is all for that file

3. Open out.php in your pliggroot directory. include this:
$db->query("UPDATE " . table_links . " SET clicks = clicks + 1 WHERE link_id = " . $id); just before header("HTTP/1.1 301 Moved Permanently");

4. open up link_summary.tpl in your templates directory and include this:
<span class="clicks">
Views : {$clicks}
</span>
where you want the clicks to be displayed. In your css fine you can define how it should look by creating an entry class clicks and defining it.

Well, that is about it. As I said this is my solution. I am certain there can be an optimized version, but this method does get things to work. Remember you can check it out at Meshedlinks / Popular

Am working on displaying and viewing links by votes. So for instance you have a tab at the top that says top links by votes or upcoming links by votes, if you get what I mean.

If you have any questions don't hesitate to post them.
you have the zip file? thank you
Reply With Quote
  #37 (permalink)  
Old 11-18-2007, 10:00 PM
netwb's Avatar
Casual Pligger/Coder
Pligg Version: 1.0
Pligg Template: wistie
 
Join Date: Dec 2006
Location: Bruxelles
Posts: 86
Quote:
Originally Posted by ozo View Post
Hey thanks this is one thing I left out that is nice.

Add this code segment to story.php in your root pligg directory

//Update number of clicks here
$db->query("UPDATE " . table_links . " SET clicks = clicks + 1 WHERE link_id = " . $id);

before:
// log the pageview
$pageview = new Pageview;
$pageview->type='story';
$pageview->page_id=$link->id;
$pageview->user_id=$current_user->user_id;
require_once(mnminclude.'check_behind_proxy.php');
$pageview->user_ip=check_ip_behind_proxy();

That should do the trick. Cheers!
You have the alls zip file?
thanks
Reply With Quote
  #38 (permalink)  
Old 01-04-2008, 06:47 PM
netwb's Avatar
Casual Pligger/Coder
Pligg Version: 1.0
Pligg Template: wistie
 
Join Date: Dec 2006
Location: Bruxelles
Posts: 86
Quote:
Originally Posted by ozo View Post
Hey I implemented a way to do this but I don't vouch that this is the best way to do it, but it worked for me @ Meshedlinks / Popular, you can see it in action. Follow this steps - however this requires that you have a little, just a little, technical knowledge:

1. create a field in your pligg_links table to store the number of clicks (NOTE: I guess this can be done simply by using extrafields, but I guess someone can work on this solution and have something better)
To create field in your pligg_links table execute this against your database :
ALTER TABLE pligg_links ADD COLUMN clicks BIGINT DEFAULT 1;

2. Modify link.php (in libs folder as follows):
a. add var $clicks = 1; just after var $current_user_reports = 0;
b. replace this:
$db->query("UPDATE " . table_links . " set link_summary='$link_summary', link_title_url='$link_title_url', link_url='$link_url', link_url_title='$link_url_title', link_title='$link_title', link_content='$link_content', link_tags='$link_tags', link_field1='$link_field1', link_field2='$link_field2', link_field3='$link_field3', link_field4='$link_field4', link_field5='$link_field5', link_field6='$link_field6', link_field7='$link_field7', link_field8='$link_field8', link_field9='$link_field9', link_field10='$link_field10', link_field11='$link_field11', link_field12='$link_field12', link_field13='$link_field13', link_field14='$link_field14', link_field15='$link_field15', clicks='$clicks' WHERE link_id=$this->id");
with the $db->query you have in the store function. or alternatively just include ,clicks='$clicks' after $link_field15 in the $db->query function in the store function.
c. In the read function look for if($link) and at the end of it where you have $this->link_summary = $link->link_summary; include $this->clicks = $link->clicks; just below it.
d. In read_basic function replace the $db->get_row.... by $db->get_row("SELECT 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"))) OR simply append , clicks to $db->get row just after link_published_date
e. add $this->clicks=$link->clicks; just after $this->published_date=unixtimestamp($date); still in read_basic
f. add this entry : $smarty->assign('clicks', $this->clicks); just after $smarty->assign('link_category', $this->category_name());
That is all for that file

3. Open out.php in your pliggroot directory. include this:
$db->query("UPDATE " . table_links . " SET clicks = clicks + 1 WHERE link_id = " . $id); just before header("HTTP/1.1 301 Moved Permanently");

4. open up link_summary.tpl in your templates directory and include this:
<span class="clicks">
Views : {$clicks}
</span>
where you want the clicks to be displayed. In your css fine you can define how it should look by creating an entry class clicks and defining it.

Well, that is about it. As I said this is my solution. I am certain there can be an optimized version, but this method does get things to work. Remember you can check it out at Meshedlinks / Popular

Am working on displaying and viewing links by votes. So for instance you have a tab at the top that says top links by votes or upcoming links by votes, if you get what I mean.

If you have any questions don't hesitate to post them.
THANKS I THIS VERY GOOD
Reply With Quote
  #39 (permalink)  
Old 07-07-2010, 03:16 PM
New Pligger
Pligg Version: 1.0.1
Pligg Template: Skynews
 
Join Date: Jun 2008
Posts: 23
I want to implement this in my page...... There's any updates

Thanks
Reply With Quote
  #40 (permalink)  
Old 07-07-2010, 04:37 PM
New Pligger
 
Join Date: Jun 2010
Posts: 3
I want it too..
please~
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Clicks instead of Votes kahunabear Questions and Comments 14 11-21-2010 09:57 PM
[mod] count clicks instead of votes abcdefgary Questions and Comments 6 06-15-2008 12:34 AM
News based on Clicks instead of Votes mde05 Questions and Comments 2 01-14-2008 09:32 AM
users total votes? inggenia Questions and Comments 2 07-09-2007 08:44 AM
Registering Clicks instead of Votes kahunabear Questions and Comments 2 02-01-2007 07:50 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development