The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
My odd project
Folks-
I'm trying to build something that's not-a-forum using vB3... On the forum home page, I want to display two less threads than are actually in each forum (a long explanation, that I'm happy to skip). The template variable, $forum[threadcount], gives me the actual count?but it appears that it is a string, rather than a value. Is there any way that I can convert the variable to a value, perform an operation on it, convert the result back to a string?within the template? --don |
#2
|
|||
|
|||
I guess it depends on the string format. If it automatically converts to the right integer then you might be able to do it (although I'm not certain offhand), otherwise you'd need to use a plugin.
|
#3
|
|||
|
|||
$threadcount = intval($forum[threadcount]);
|
#4
|
|||
|
|||
Well, yeah, in a plugin. But you can't put that in a template. Also, if the number is formatted with a thousands separator (like a comma) then that will work until there are more than 1000 threads (I found this out the hard way with user post).
|
#5
|
|||
|
|||
Guess I need to rethink my approach.
|
#6
|
|||
|
|||
Quote:
Try this plugin for "forumbit_display" Code:
$forum['threadcount'] = vb_number_format(intval($forum['threadcount']) - 2); |
#7
|
|||
|
|||
Well, the OP says "within the template", so I took that to mean without a plugin. HTML can't do math but there are {vb:math ...} and {vb:number ...} template tags for doing simple arithmetic and formatting a number.
Quote:
|
#8
|
|||
|
|||
I don't see any practical way to do it in a template. Youre right about commas. This should catch it before it's formatted:
Code:
$forum['threadcount'] = vb_number_format(intval($counters["$forum[forumid]"]['threadcount']) - 2); |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|