The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Ajax - Trying to count thread views on outgoing links.
Hi,
I will preface by saying I am a total noob and I really know nothing. I am trying to use one of my forums as a link dump/directory. I am trying to count the thread views on an outbound link (ie clicking the link increases thread views by 1). I found a snippet of code on another forum and I am trying to get it to fill my needs: Code:
<script type="text/javascript"> function trackClick( id ){ var url = "http://www.amateurpornster.com/showthread.php?t=" + id; xmlRequestObj = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP") xmlRequestObj.open("GET", url, true); xmlRequestObj.send(null); return false; } </script> Code:
<a href=<if condition="in_array($forumid, array(3))">"$thread[preview]" onClick="trackClick( '$thread[threadid]' );" target="_blank"<else />"showthread.php?$session[sessionurl]t=$thread[threadid]"</if> id="thread_title_$thread[realthreadid]"<if condition="$show['gotonewpost']"> style="font-weight:bold"</if>>$thread[threadtitle]</a> Any help would be appreciated, or just tell me it wont work and I will look for another solution! Cheers, Ian |
#2
|
||||
|
||||
No clue, but Google Analyitcs provides this information and its free and a lot easier to implement
|
#3
|
||||
|
||||
But then you'll get an increase on the thread view by 2 (one for entering thread, one for clicking link), and this isn't what you want, right?
|
#4
|
|||
|
|||
Quote:
Quote:
When they click the thread title link they wont be taken to the thread: Code:
<a href=<if condition="in_array($forumid, array(3))">"$thread[preview]" onClick="trackClick( '$thread[threadid]' );" target="_blank"<else /> ... --------------- Added [DATE]1205605006[/DATE] at [TIME]1205605006[/TIME] --------------- Ok my mistake, this seems to be working. Since my board is not live yet I am the only one on the site so the cron to count thread views wasnt getting triggered. Now that I know the function is working, I don't think showthread.php is appropriate for this when I can have a much smaller file accomplish the same. Can anyone show me how to write a file that would basically: UPDATE " . TABLE_PREFIX . "thread SET views = views + 1 WHERE threadid = the thread id that was clicked Cheers, Ian |
#5
|
|||
|
|||
Quote:
Basically I want to make a file (track.php) that when clicked adds a view to the thread table. So clicking on track.php?id=15 would update thread 15 with one more view. Not sure if its possible to have it update hourly like regular thread views? Can someone help me out on this one pls. Thanks in advance, Ian |
#6
|
|||
|
|||
Here is the php code for it
PHP Code:
|
#7
|
|||
|
|||
Quote:
Cheers, Ian |
#8
|
||||
|
||||
PHP Code:
|
#9
|
|||
|
|||
Hmmm, the above code does not seem to be working, the views are not being added. If I go to the file in my browser (ie:www.mydomain.com/track.php?id=15) I get a white screen (that is expected I guess) and there is no error or anything, views not being added. Tried changing the admincp option to both hourly and instant but no changes.
Cheers |
#10
|
||||
|
||||
Please try this and report the output.
PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|