The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#20
|
|||
|
|||
![]()
Here is some conditional usage that you may want to ponder. Of course all of this can and maybe should be done in PHP, but sometimes this is more fun. I discovered quite a few interesting things when enhancing the template system.
One of the things I modified in the template system is a 'break' for the 'each' conditional. I am pointing this out, because in the crazy example below the routine continues to iterate the array and we may have already found our resultant. Code:
<vb:comment> Iterates an array for basically no reason, and if a value was found in the array the create a new variable inside the template for altering a dynamic response. (tbworld method) </vb:comment> <vb:each from="show" key="show_key" value="show_value"> <vb:comment> <!-- Just to show usage --> key: {vb:var show_key} <br> value: {vb:var show_value}<br> </vb:comment> <!-- Check for existance of key in $show --> <vb:if condition="array_key_exists('member', $show) AND (!isset($newvar))"> <div>Array Key Exists!</div> <!-- create or set a value to a variable --> <vb:if condition="$newvar='Yes we created a new variable $newvar!'"></vb:if> </vb:if> </vb:each> <!-- Display the new variable we just created --> <dl> <dd>Did we create a new variable?</dd> <dt>{vb:raw newvar}</dt> </dl> <!-- --------------------------------------------------------------- --> <!-- Key exists if not NULL --> <vb:if condition="isset($show['member'])">--isset test --<br /></vb:if> <!-- Expansion on the above examples, Use with caution! --> <!-- Create a new Array --> <vb:if condition="$new_array = array('member', 'fruit', 'fish')" ></vb:if> <!-- Create a new Key field variable --> <vb:if condition="$new_test_key='member'"></vb:if> <!-- Create a variable resultant --> <vb:if condition="$resultant=in_array($new_array[$new_test_key], $show, false)" >Test Key exist in $show array<br /></vb:if> ![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|