vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   help with phrases.. what are {1} ?? (https://vborg.vbsupport.ru/showthread.php?t=165822)

!!!cyr0n_k0r 12-21-2007 11:15 PM

help with phrases.. what are {1} ??
 
Code:

There have been <b>{1}</b> post{7} and <b>{2}</b> thread{8} since your last visit at {3}.
The above is part of a phrase. I am trying to use on a non VB page. I have all the correct backend stuff, as everything shows up correctly when calling the phrase, however the things inside {1}, {7} which should be numbers aren't being displayed.

What are these things?
I'm new to coding in VB 3.5.x and have been out of the loop for several years.

Guest190829 12-21-2007 11:22 PM

It's a wrapper for the sprintf function, basically those are the inputted variables that are inserted into the phrase. The number inside the {} is based on the order of the parameters of the vbphrase function. (Which I can't remember off the top of my head)

construct_phrase() maybe...

!!!cyr0n_k0r 12-21-2007 11:48 PM

and where can I find these sprintf functions? Where can they be edited?

Also, why aren't they showing up on a non-VB page when everything else VB related does. I can call for templates and phrases, but these wrappers don't work.

Guest190829 12-22-2007 12:02 AM

Here is the info:

Quote:

https://vborg.vbsupport.ru/external/2008/08/6.png construct_phrase (line 2107)
Construct Phrase
this function is actually just a wrapper for sprintf but makes identification of phrase code easier and will not error if there are no additional arguments. The first parameter is the phrase text, and the (unlimited number of) following parameters are the variables to be parsed into that phrase.
  • return: The parsed phrase
string construct_phrase (string 0, mixed 1, mixed 2)
  • string 0: Text of the phrase
  • mixed 1: First variable to be inserted
  • mixed 2: Nth variable to be inserted

You need to call that and add the appropriate values with PHP (A plugin or inside the php file you are using)

!!!cyr0n_k0r 12-22-2007 12:25 AM

Thanks!

For people ever having the same issues this is the fix.

Code:

<phrase 1="$pmbox[lastvisitdate]" 2="$pmbox[lastvisittime]">$vbphrase[last_visited_x_at_y]</phrase>
Notice the 1="blah blah"

That would be what is filled into {1}

and so on. :D

--------------- Added [DATE]1198292190[/DATE] at [TIME]1198292190[/TIME] ---------------

Well, it seems some work and some don't. Can anyone shed light as to why the second group of wrappers aren't working?

PHP Code:

<phrase 1="{$bbuserinfo['posts']}">$vbphrase[kor_comments]</phrase><br><br>
<
phrase 1="{$numbermembers}2="$totalthreads3="$totalposts">$vbphrase[kor_forum_stats]</phrase

The first phrase works fine, the one that calls for $bbuserinfo[posts]

But the second group of stats aren't working. $totalposts, etc.

I have installed the "Welcome Panel Rewrite" hack and the stats work on the index.php, but on my own custom page, they numbers aren't showing up, just the text.

Guest190829 12-22-2007 01:58 AM

The are not working because they only have scope within the plugins of the Member Rewrite modifications. You are either going to have to duplicate code or create your own variation of it.

!!!cyr0n_k0r 12-22-2007 03:04 AM

The hack doesn't modify PHP files or templates though. So how is it that it will work in index.php, but not my page?

What needs to be called to allows those phrases to work?

--------------- Added [DATE]1198300451[/DATE] at [TIME]1198300451[/TIME] ---------------

Also, it can't be the hack, because there is a built in vbulletin variable for total number of members registered.

$numbermembers


However, even when I call that it still isn't working.

Guest190829 12-22-2007 03:16 AM

Okay, even it they are default vBulletin variables, they are out of scope with your custom script.

!!!cyr0n_k0r 12-22-2007 04:13 AM

correct :D

Here is the solution for anyone searching.

PHP Code:

// ### BOARD STATISTICS #################################################

// get total threads & posts from the forumcache
$totalthreads 0;
$totalposts 0;
if (
is_array($vbulletin->forumcache))
{
    foreach (
$vbulletin->forumcache AS $forum)
    {
        
$totalthreads += $forum['threadcount'];
        
$totalposts += $forum['replycount'];
    }
}
$totalthreads vb_number_format($totalthreads);
$totalposts vb_number_format($totalposts);

// get total members and newest member from template
$numbermembers vb_number_format($vbulletin->userstats['numbermembers']);
// ### BOARD STATISTICS ################################################# 

Add this code to your custom PHP file.

Also include this:
PHP Code:

require_once(DIR '/includes/functions_forumlist.php');
cache_ordered_forums(1); 

Add that below require global.


All times are GMT. The time now is 11:40 AM.

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.02133 seconds
  • Memory Usage 1,744KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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