developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#837 closed new feature (fixed)

jTpl plugins: fetchzone

Reported by: Julien Owned by: Julien
Priority: normal Milestone: Jelix 1.1.1
Component: jelix:plugins:tpl Version: trunk
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

Description

Sometimes it can be useful to know if a zone called from a template would display something or not.

Here's an example:

{ifzonenotempty 'navigation', array('parent'=>3)}
<div id="submenu">
    <h2>Submenu</h2>
    {zonecontent}
    <hr />
</div>
{/ifzonenotempty}

(the is also a 'ifzoneempty' test block)

'zonecontent' is a new plugin that holds the content of the zone called in 'ifzone(not)empty' blocks

Attachments (2)

837-jTpl-plugins-ifzoneempty-ifzonenotempty-zonecontent.diff (4.8 KB) - added by Julien 12 years ago.
837-jTpl-plugins-fetchzonecontent.diff (2.0 KB) - added by Julien 12 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 12 years ago by Julien

  • Status changed from new to assigned

comment:2 Changed 12 years ago by laurentj

  • review changed from review? to review-

problem with zonecontent if there are nested ifzone*... I think $t->_privateVars__zonecontent? should be an associative array where the key is a unique identifier of the zone..

the zonecontent plugin should accept same argument as zone/ifzone so we could display the right content.

comment:3 Changed 12 years ago by Julien

you're right, I didn't consider nested ifzone blocks in these plugins because it was not my need ;)

I will change that, trying to keep it simple

comment:4 Changed 12 years ago by Julien

  • review changed from review- to review?

I found a more flexible way to solve the problem and maybe some others.

Here's a new plug-in called 'fetchzonecontent' that will store the content of a zone in a tpl var the user can choose, then making nested things not a problem.

Then it can be tested, display, everything just like a standard jTpl var:

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

Changed 12 years ago by Julien

comment:5 Changed 12 years ago by laurentj

  • review changed from review? to review+

Yes, that's better. ok to land it into 1.1.x + trunk

comment:6 Changed 12 years ago by laurentj

  • Documentation needed set

comment:7 Changed 12 years ago by Julien

  • Resolution set to fixed
  • Status changed from assigned to closed
  • Summary changed from jTpl plugins: ifzoneempty and ifzonenotempty blocks to jTpl plugins: fetchzonecontent

committed in the trunk and 1.1.x, r1320

comment:8 Changed 12 years ago by bballizlife

I'm a little bit late on this ticket, great idea for that plugin. I just have a suggestion. As we display a zone in a template with zone i would have named your plugin fetchzone instead of fetchzonecontent.

My 2 cents ;)

comment:9 Changed 12 years ago by Julien

why not :)

I can change that, no problem, if it sounds clear enough for everybody.

comment:10 Changed 12 years ago by laurentj

bballizlife : +1

comment:11 Changed 12 years ago by bballizlife

ok so this would be nice if you could change the name. thanks Julien !

comment:12 Changed 12 years ago by Julien

  • Summary changed from jTpl plugins: fetchzonecontent to jTpl plugins: fetchzone

done, r1321

Note: See TracTickets for help on using tickets.