Templates : dynamic include

Jean-Baptiste

Well-known member
Hello,

I would like to dynamicly include a template :
Code:
<xen:include template="$myTemplate" />

It's not allowing me to save the template, any way to do it ?

Kind regards,
:)
 
Unlikely to be possible. After you hit save the template is compiled and the included template is compiled in to it. Therefore the compiler would need to know the value of $myTemplate which, presumably at that point, it doesn't.
 
In theory, you can do this in the view.

I'm not sure why it needs to be dynamic, or under what conditions it needs to be dynamic... but the view would be the place to do this:

PHP:
$this->_params['someHtml'] = $this->_renderer->createTemplateObject($aDynamicTemplateName, $params);

You can then use that in your template:

HTML:
{xen:raw $someHtml}

In conjunction with this, you may want to pre load your template with the template_create event listener.
 
In theory, you can do this in the view.

I'm not sure why it needs to be dynamic, or under what conditions it needs to be dynamic... but the view would be the place to do this:

PHP:
$this->_params['someHtml'] = $this->_renderer->createTemplateObject($aDynamicTemplateName, $params);

You can then use that in your template:

HTML:
{xen:raw $someHtml}

In conjunction with this, you may want to pre load your template with the template_create event listener.

You rock as always Chris, I don't need more thanks you very much that will do the job!! :)
 
Top Bottom