API - XOOPS 2.5.11 Beta 2
By monxoops.fr
compiler.foreachq.php File Reference

Namespaces

namespace  xos_opal
 

Functions

 smarty_compiler_foreachq ($argStr, &$comp)
 

Function Documentation

◆ smarty_compiler_foreachq()

smarty_compiler_foreachq (   $argStr,
$comp 
)

Quick foreach template plug-in

This plug-in works as a direct replacement for the original Smarty foreach function.

The difference with foreach is minimal in terms of functionality, but can boost your templates a lot: foreach duplicates the content of the variable that is iterated, to ensure non-array variables can be specified freely. This implementation does not do that, but as a consequence requires that the variable you specify in the from parameter is an array or (when using PHP5) an object. Check the difference between the code generated by foreach and foreachq to understand completely.

Note: to use foreachq, only the opening tag has to be replaced. The closing tab still remains {/foreach}

// Iterate, slow version {foreach from=$array item=elt} {$elt} {/foreach} // Iterate, fast version {foreachq from=$array item=elt} {$elt} {/foreach}

Parameters
$argStr
$comp
Returns
string