vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   HITCounter - Link Forum Counter (https://vborg.vbsupport.ru/showthread.php?t=93640)

b6gm6n 08-04-2005 10:00 PM

HITCounter - Link Forum Counter
 
This is a port originally By Zajako and Mone.

With kind permission i've updated the mod for vBulletin 3.5, this version comes with an enhancement, i.e via your ACP (forum manager) you can adjust the starting value for any counter.

Installation is done easily via the importing of an xml file.

See screenshots!

Enjoy!

Update : Huge Respect to KirbyDE who really is the genius behind this mod, cheers dude.

Update 1.3 : optimized code - (no more updates to totals) - Thanx KirbyDE

If you use this mod please click Install - cheers!

Boofo 08-05-2005 12:28 AM

Can't you do the file edit via a plug-in?

b6gm6n 08-05-2005 12:37 AM

Quote:

Originally Posted by Boofo
Can't you do the file edit via a plug-in?

would be nice yeah... but how does one edit the forum home template on the fly via a plugin..? - stumped me for now anyways... :)

-b6

Boofo 08-05-2005 12:51 AM

Quote:

Originally Posted by b6gm6n
would be nice yeah... but how does one edit the forum home template on the fly via a plugin..? - stumped me for now anyways... :)

-b6

Oh, template edit. I thought it was a file edit. My mistake, sorry. ;)

Shouldn't this be in plug-ins then?

b6gm6n 08-05-2005 12:59 AM

No need to be sorry your right, there is a file edit in three places within "functions_forumlist.php", everything else gets automagically installed via the xml file settings, template, queries etc...

The file edit merges the new 'linkhits' template into the forum home display, maybe the next version will be free of file edits... which would be great!

-b6

Boofo 08-05-2005 01:01 AM

There should be some hooks you can use for the file edits, though, shouldn't there?

Andreas 08-05-2005 01:39 AM

The Template is not the Problem, can be done with a Plugin.

Hook: forumbit_display
PHP Code:

if ($forum['link'])
{
    
$forum['replycount'] = '';
    
$forum['threadcount'] = '';
    eval(
'$forum[\'lastpostinfo\']  = "' fetch_template('linkhits') . '";');


This kicks off 1 File edit.

However, getting the count doesn't seem to be possible without the File edit.
The other Option would be to use a Query. But this would add 1 Query to Forumhome and every forumdisplay.php call where the Forum being displayed contains sub-forums that are links.
Or the Forumcache would have to be rebuild upon every Hit, which is even worse IMHO.

However, some furhter suggestions:

Your Counter-Update seems to be run every Time smth. is being done in ACP?
I'd suggest to get rid of the Settings and the admin_global Plugin.
Instead, make a new control in Forum Manager that shows the current Value so the User can just input it's own.

Hook: forumdata_start
PHP Code:

$this->validfields['linkhits'] = array(TYPE_UINTREQ_NO); 

Hook: forumadmin_edit_form
PHP Code:

if (trim($forum['link'] != ''))
{
    
$check $db->query_first("SELECT linkhits FROM " TABLE_PREFIX "forum WHERE forumid = $forum[forumid]");
    
print_table_header('Forum Link Hit Counter');
    
print_input_row('Hit Counter Value<dfn>Here you can manually adjust the Hit-Counter for this Forum-Link</dfn>''forum[linkhits]'$check['linkhits']);


The check-query isn't ideal, but necessary as the Forum Manager displays cached Data

Don't execute the Update in Global-Start, as this causes 1 additional Query for every Forum being displayed, no matter if it is a Link or not.

Hook: header_redirect
PHP Code:

global $foruminfo;
if (
trim($foruminfo['link']) != '')
{
    
$vbulletin->db->query("UPDATE " TABLE_PREFIX "forum SET linkhits = linkhits +1 WHERE forumid=$foruminfo[forumid]");


You should also cache the Template on forumdisplay, as it might be shown here too.

Hook: cache_templates
PHP Code:

if (THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'forumdisplay')
{
    
$globaltemplates  array_merge($globaltemplates, array('linkhits'));



b6gm6n 08-05-2005 02:05 AM

Thanx KirbyDE, i'll look into this...cheers

-b6

Boofo 08-05-2005 02:26 AM

There you go! I knew Kirby would be able to help. ;)

FleaBag 08-05-2005 10:58 AM

b6gm6n - is the username Kingpin related?

b6gm6n 08-05-2005 11:37 AM

Quote:

Originally Posted by FleaBag
b6gm6n - is the username Kingpin related?

Kingpin the game/film? - well that would be telling!

-b6

FleaBag 08-06-2005 12:37 AM

The game...

If it is was just wondering if you were familiar with what was poisonville.com / is now poisonville.org. If not then you're probably wondering what the hell I'm talking about.

Andreas 08-07-2005 09:09 AM

Just an idea to get rid of the remaining File Edit:
As Forums that act as Links don't have Threads, what about using the threadcount or replycount field for the Counter?
This way it would be automatically queried by cache_ordered_forums().

Boofo 08-07-2005 09:13 AM

Quote:

Originally Posted by KirbyDE
Just an idea to get rid of the remaining File Edit:
As Forums that act as Links don't have Threads, what about using the threadcount or replycount field for the Counter?
This way it would be automatically queried by cache_ordered_forums().

But the link counter would show how many times the link had been clicked. ;)

Andreas 08-07-2005 09:50 AM

And that wouldn't change if it just used another database field :)

Boofo 08-07-2005 09:53 AM

Quote:

Originally Posted by KirbyDE
And that wouldn't change if it just used another database field :)

That'll work. ;)

b6gm6n 08-07-2005 12:40 PM

i see what you mean...(i think) so i'd have to alter the template, i already have the extra database field... i dunno if this is possible using my limited knowledge of php/modding etc... i'd need some more advice ;)

-b6

Andreas 08-07-2005 07:43 PM

Install Code for new Version (I'd suggest to remove the old Install Code)
PHP Code:

$db->hide_errors();
$db->query_write("UPDATE " TABLE_PREFIX "forum SET replycount=linkhits WHERE link != ''");
$db->query_write("ALTER TABLE " TABLE_PREFIX "forum DROP linkhits");
$db->show_errors(); 

Uninstall-Code
PHP Code:

$db->query_write("UPDATE " TABLE_PREFIX "forum SET replycount=0 WHERE link != ''"); 

Then in the Plugins and Template change all references to linkhits into replycount - Done.
The File-Edit then will not be necessary any longer.

Boofo 08-07-2005 11:52 PM

Quote:

Originally Posted by KirbyDE
Install Code for new Version (I'd suggest to remove the old Install Code)
PHP Code:

$db->hide_errors();
$db->query_write("UPDATE " TABLE_PREFIX "forum SET replycount=linkhits WHERE link != ''");
$db->query_write("ALTER TABLE " TABLE_PREFIX "forum DROP linkhits");
$db->show_errors(); 

Uninstall-Code
PHP Code:

$db->query_write("UPDATE " TABLE_PREFIX "forum SET replycount=0 WHERE link != ''"); 

Then in the Plugins and Template change all references to linkhits into replycount - Done.
The File-Edit then will not be necessary any longer.

And this will count link hits, too? ;)

Andreas 08-07-2005 11:54 PM

Nah, that would only be the new Install/Uninstall Code for the Product.

b6gm6n 08-08-2005 01:37 AM

seems to be working within the forum admin, but it's not showing within the forum home, i've reset the edited *.php file (no edits) and followed your instructions, i've added the new install code, un-installed & exported, done all i can do find the reason, but nothing... still won't show.

-b6

b6gm6n 08-08-2005 01:41 AM

still ok?
Code:

if (THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'forumdisplay')
{
    $globaltemplates  = array_merge($globaltemplates, array('linkhits'));
}

i've tried 'replycount' with no luck

template is :
Code:

<div class="smallfont" align="$stylevar[left]" padding left="20">
<img class="inlineimg" src="$stylevar[imgdir_button]/lastpost.gif" alt="Redirect to $forum[title]" border="0" /> <a href="forumdisplay.php?$session[sessionurl]f=$forum[forumid]" title="Redirect to $forum[title]"><b>Redirected Hits:</b></a> $forum[replycount]</div>

which shows, but no number for replycount, just blank

Andreas 08-08-2005 04:11 AM

That's due to construct_forum_bit() wiping out the Value before Hook forumbit_display gets called.
But you should be able to restore it:
PHP Code:

$forum['replycount'] = $vbulletin->forumcache["$forumid"]['replycount']; 


b6gm6n 08-08-2005 11:44 AM

The template isn't picking it up, but the value is showing ok...check the attached, almost there...

i've placed
Code:

$forum['replycount'] = $vbulletin->forumcache["$forumid"]['replycount'];
below the exisiting code in the hook : forumbit_display, it's the only location that'll work and show the values.

in the template > "$forum[replycount]" does nothing and i've tried re-jigging the merge template part to :
Code:

if ($forum['link'])
{
    eval('$forum[\'replycount\']  = "' . fetch_template('linkhits') . '";');
    $forum['threadcount'] = '';
    $forum['lastpostinfo'] = '';
}

but it does not show the template (redirected hits etc)

so yet again i'm at an impass...bugger :) i'll need some more help again me thinks :)

-b6

Andreas 08-08-2005 02:35 PM

See the attached XML; works fine for me.

b6gm6n 08-08-2005 02:48 PM

wow it does to, thanx so much, you are a freaking genius when it comes to this stuff... i'll upgrade the distro asap, boofo can move this little mod (i kinda helped with) to the extensions section, thanx again Kirby...massive kudos to you.

-b6

Boofo 08-08-2005 02:51 PM

If the xml is all you need, then it can go in plug-ins, right?

Andreas 08-08-2005 02:54 PM

No, it's the complete Package (aka Product XML).

b6gm6n 08-08-2005 02:57 PM

updated, please move to where ever you see fit, cheers guys.

-b6

Andreas 08-08-2005 02:59 PM

Moved to Plugins.
Another File Edit nailed ... strike :D

Boofo 08-08-2005 03:04 PM

hehe Kirby, you kill me! LOL

Boofo 08-08-2005 03:28 PM

Shouldn't there be a template eidt for this? ;)

P.Jackson 08-12-2005 09:27 PM

cant get this to work the plugin shows blank for me :(

Andreas 08-12-2005 09:43 PM

Common Mistake: You must import this as a Product.

b6gm6n 08-12-2005 09:51 PM

cheers kirby, was just about to say that! :)

-b6

c0d3x 08-13-2005 09:14 AM

if i change skin i will have to reinstall the plugin?

Andreas 08-13-2005 09:21 AM

It does work in all Styles.

Boofo 08-13-2005 09:21 AM

What do you put in what template to get it to show anything?

Boofo 08-13-2005 09:32 AM

Quote:

Originally Posted by KirbyDE
No. Just Create a postbit_first Template.

Wrong thread? ;)

b6gm6n 08-13-2005 09:40 AM

Yeah i think so Boofo... ;) - This little Mod should work with all skins without a re-install

-b6


All times are GMT. The time now is 08:01 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01534 seconds
  • Memory Usage 1,843KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (10)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete