The Arcive of vBulletin Modifications Site. |
|
Details »»
|
|||||||||||||||||||||||||
Hi,
maybe you know that problem, just checking if $foo isset, if not dont display option $bar. this is kinda nasty cuz you gotta edit the .php file and the template. i've thought about conditional templates and wrote that extremly short hack: ./admin/functions.php before PHP Code:
PHP Code:
from now on you can use the iif() function: Template: Code:
... this user has ? . iif($userposts == 1, ?one post?, ?$userpost posts?) . ? since ... Code:
... this user has " . iif($userposts > 0, "not a single post", "$userpost posts") . " since ... well thats not easy to explain, i hope you got then point ![]() note this isnt tested very well, use with care! Show Your Support
|
|||||||||||||||||||||||||
| Comments |
|
#2
|
|||
|
|||
|
Awesome! This is just what I've been looking for for a long time. Fantastic work! From my quick-and-dirty testing, this appears to be the answer to my conditional templates dreams...
|
|
#3
|
||||
|
||||
|
what is the point of this :S?
|
|
#4
|
|||
|
|||
|
It allows you to include conditional statements in your templates. For example, on my site which is PDA-oriented, I want to display a different layout if a visitor is using a PDA browser (e.g. Pocket Internet Explorer), which obviously has a lot less screen space to play with.
Therefore, I would include a conditional check to see whether a PDA browser is detected or not before deciding which elements of the template to display, and what the layout should be. |
|
#5
|
|||
|
|||
|
Conditional templates will be a feature of vb3....
|
|
#6
|
||||
|
||||
|
I still don't get it. Any examples of this in use?
![]() Quote:
|
|
#7
|
|||
|
|||
|
I'm still checking, but it appears that the conditional check doesn't work correctly in the postbit templates - the result always comes up as false.
|
|
#8
|
|||
|
|||
|
Anyone know what's so special about the postbit templates that they set all variables to null?
For example, if I set a variable $mobile to 1, it will be recognised as such in the showthread template. In the postbit template, however, it always comes up as null (even if I include a php file in the postbit template that specifically sets it to 1). |
|
#9
|
|||
|
|||
|
Quote:
|
|
#10
|
||||
|
||||
|
it's because getpostbit is a real function, so it doesn't use variables from showthread.php
you have to globalize your variable first
|
![]() |
|
|