View Full Version : help with phrases.. what are {1} ??
!!!cyr0n_k0r
12-21-2007, 11:15 PM
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:
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.
<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 1198292190 at 1198292190 ---------------
Well, it seems some work and some don't. Can anyone shed light as to why the second group of wrappers aren't working?
<phrase 1="{$bbuserinfo['posts']}">$vbphrase[kor_comments]</phrase><br><br>
<phrase 1="{$numbermembers}" 2="$totalthreads" 3="$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 1198300451 at 1198300451 ---------------
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.
// ### 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:
require_once(DIR . '/includes/functions_forumlist.php');
cache_ordered_forums(1);
Add that below require global.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.