The Arcive of vBulletin Modifications Site. |
|
|
#1
|
||||
|
||||
|
Sample code:
HTML Code:
<vb:if condition="$first_item = X($myvar)"> <!-- do something --> </vb:if> <vb:each from="myvar" key="k" value="v"> <!-- do something --> </vb:each> Code:
Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 3555 PS: I'm aware of the counter workaround in vb:each but that doesn't go well with how I wanna write the template. The only workaround I can now think of array_shift the value in the actual php code (rather than in template) before registering the variable to the template which is something I wanna avoid. btw, you'll need to add this plug in to use these functions: hook: template_safe_functions code: $safe_functions[] = 'each'; |
|
#2
|
|||
|
|||
|
I tried it using array_shift and it seems to work.
Code:
$myvar = array('First', 'Second', 'Third');
$templater = vB_Template::create('test_template');
$templater->register('myvar', $myvar);
print_output($templater->render());
Code:
<vb:if condition="$first_item = array_shift($myvar)">
First: {vb:raw first_item}<BR/>
</vb:if>
<vb:each from="myvar" key="k" value="v">
Loop: {vb:raw k} {vb:raw v}<BR/>
</vb:each>
I couldn't see how you could get to fetch_error_array() with $errors not an array unless maybe you have a plugin that changes $errors (maybe using hook template_compile?) or maybe a custom tag. |
|
#3
|
||||
|
||||
|
I think it has to do with my array being multi-level :/
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|