Quick links: Content - sections - sub sections
EN FR
Jelix 1.5.7

Section: Miscellaneous

« Modifiers ^ Template plugins Media »
Switch to language: FR

zone

Displays the content of a zone


  <div>
    {zone 'module~a_zone'}
  </div>

this is equivalent to:


    $tpl->assignZone('ZONE','module~a_zone');

<div>
    {$ZONE}
</div> </code>

fetchzone

With this plugin, you can get the content of a zone, so you can display it several times or you can test its content before the display.


{fetchzonecontent 'submenu', 'navigation', array('parent'=>3)}
{if $submenu !== ''}
<div id="submenu">
    <h2>Submenu</h2>
    {$submenu}
    <hr />
</div>
{/if}

common : cycle

The plugin cycle allow to display cyclic values. It is useful in loops, when you want to display a different value at each step. Typical example:


  {foreach $list as $item}
   <tr class="{cycle array('odd','even')}">
      <td>...<td>
   </tr>
  {/foreach}

Here, the plugin will display 'odd', then 'even', then 'odd' etc.

Controlling a cycle

There are two other plugins to have a better control on a cycle : cycle_init to initialize a cycle, and cycle_reset to reset the cycle (the next value will be the first value of the list).


  {cycle_init 'style1,style2,style3'}
  {foreach $list as $item}
   <tr class="{cycle}">
      <td>...<td>
   </tr>
   {if $item == 'truc'}
      {cycle_reset}
   {/if}
  {/foreach}

Note that cycle_init accepts a string with values separated by a comma, or an array.

Named cycles

Perhaps you would want to reuse the same cycle in several places, or to use differents cycles in the same loop. To do it, you should name your cycle, by given a name at the first argument.


  {foreach $list as $item}
   <tr class="{cycle 'first', array('odd','even')}">
      <td class="{cycle 'styletd',array('style1,style2,style3')}">...<td>
   </tr>
  {/foreach}


  {cycle_init 'styles', 'style1,style2,style3'}
  {foreach $list as $item}
   <tr>
      <td class="{cycle 'styles'}">...<td>
      <td class="{cycle 'styles'}">...<td>
   </tr>
  {/foreach}

The result of the second loop will be:


   <tr>
      <td class="style1">...<td>
      <td class="style2">...<td>
   </tr>
   <tr>
      <td class="style3">...<td>
      <td class="style1">...<td>
   </tr>
   <tr>
      <td class="style2">...<td>
      <td class="style3">...<td>
   </tr>
...

resurl

Allow to use a resource form a module. File must be present in a www directory in the module.


    {resurl 'module', 'example.png'}

Parameters

Module

This is the module where the resource is located

File

The file, with it's path relative to the module's www directory

Additionnal parameters

This function plugin take 2 additionnal parameters:

In Theme ?

Pass true, as third parameter to declare if the resource is in a theme (default to false)

Escape

Pass false as fourth parameter not to escape special characters (default to true)

Others

For other plugins, see the API reference documentation