Your example looks a lot like
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.partial
the partial helper .
Giuliano
Matthias W. wrote:
>
> Hi,
> I'm going to implement a CMS.
> The first classes are created and now I'm on the menu.
>
> The menu should contain a template so that I only have to create an array
> with the menu structure and a template with the HTML.
>
>
> I've got:
> $tmpl = array(
> 'navigationClassCSS' => 'nav',
> 'menu' => array(
> array(
> 'link' => 'http://...',
> 'name' => 'Linkname',
> 'submenu' => array(
> array(
> 'link' => 'http://...',
> 'name' => 'Linkname',
> ),
> array(
> 'link' => 'http://...',
> 'name' => 'Linkname',
> ),
> ),
> ),
> array(
> 'link' => 'http://...',
> 'name' => 'Linkname',
> ),
> ),
> );
>
> Template:
> <ul class="<?=$tmpl['navigationClass'] ?>">
> <?php foreach($tmpl['menu'] as $links) { ?>
> <li>
> <a href="<?=$links['link'] ?>">
> <?=$links['name'] ?>
> </a>
> <?php if (isset($links['submenu'])) { ?>
> <?php foreach($tmpl['submenu'] as $subLinks) { ?>
> <li>
> <a href="<?=$subLinks['link']
> ?>">
> <?=$subLinks['name'] ?>
> </a>
> </li>
> <?php } ?>
> <?php } ?>
> </li>
> <?php } ?>
> </ul>
>
>
> And till now I include the template with:
>
> include 'template.phtml';
>
> But I think this is no proper way to include the template.
> I want it the following way:
>
> $template = new Template('filename.phtml', $tmpl); //$tmpl is the array
> with the placeholders
> echo $template->get(); //get the completed HTML from template
>
> Also I thought about a custom placeholder replacer to use a templates like
> this:
> <ul class="[[navigationClass]]">
> [[foreach|menu]]
> <li>
> <a href="[[menu:link]]">
> [[menu:name]]
> </a>
> [[if|menu:submenu]]
> [[foreach|menu:submenu]]
> <li>
> <a href="[[menu:submenu:link]]">
> [[menu:submenu:name]]
> </a>
> </li>
> [[/foreach|menu:submenu]]
> [[/if|submenu]]
> </li>
> [[/foreach|menu]]
> </ul>
>
>
> How can I do this?
>
> I dont want to use TemplateSystems like Smarty, because I want to keep it
> really simple.
>
> I also thought about 'compiling' the templates to reset the
> [[placeholders]] with php-code -> I've got template.tpl which will be
> compiled to template.phtml. But I think this isn't that good.
>
--
View this message in context:
http://www.nabble.com/Menu-Templating-tp22368087p22369459.html
Sent from the Zend Framework mailing list archive at Nabble.com.