vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   A little php help please to get this working correctly (https://vborg.vbsupport.ru/showthread.php?t=267852)

HMBeaty 08-02-2011 10:04 PM

A little php help please to get this working correctly
 
I'm working on making a hit counter for the forumhome and so far, have gotten this far with the code:

Plugin
Hook location: forumhome_start
PHP Code:

$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "usml_fhcounter SET count = count + 1");
$counter $db->query_first("SELECT * FROM " TABLE_PREFIX "usml_fhcounter");
$count vb_number_format($counter['count']);

$template_hook['navtab_end'] .= '<phrase 1="$count">'.$vbphrase[counter].'</phrase>'

Installcode
Code:

$db->hide_errors();

$db->query_write('CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'usml_fhcounter`(
        `count` VARCHAR(6) NOT NULL DEFAULT "",
        PRIMARY KEY  (`count`)
    ) TYPE=MyISAM;
');

$db->query_write('INSERT INTO `'.TABLE_PREFIX.'usml_fhcounter` (
        VALUES (0);
');

$db->show_errors();

It ALMOST works! The only problem I'm having is that it is printing out
Code:

Visitors: %1$s
So, how do I get %1$s to display as the number of visitors instead of.....whatever that is? lol

Thanks in advance for the help :)

Lynne 08-02-2011 10:34 PM

I think you want to use construct_phrase:

construct_phrase($vbphrase['counter'], $counter)

So something like:
PHP Code:

$template_hook['navtab_end'] .= construct_phrase($vbphrase['counter'], $counter); 


HMBeaty 08-02-2011 10:37 PM

Just tried that, an now no characters show. Just:
Code:

Visitors:
Hopefully that's an improvement lol

Lynne 08-02-2011 10:40 PM

Whoops, you need to pas $count, not $counter.

PHP Code:

$template_hook['navtab_end'] .= construct_phrase($vbphrase['counter'], $count); 



All times are GMT. The time now is 09:47 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.01635 seconds
  • Memory Usage 1,719KB
  • 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
  • (3)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete