Nesting a pair of ExpressionEngine entry tag tags in another channel entry tag pair?

I searched a bit, but I can not find any information about embedding a pair of channel tags in another.

When I try to use the following code in a template, it breaks the page, and I see that the opening {reverse_related_entries sort="desc"} displayed as plain text:

 {exp:channel:entries channel="pages"} {reverse_related_entries sort="desc"} {if show_testimonial} {exp:channel:entries channel="testimonials" orderby="random" limit="1"} <blockquote> {testimony} <cite> <span class="cite_name">{cite_name}</span><br /> <span class="cite_org">{cite_org}</span><br /> <span class="cite_title">{cite_title}</span> </cite> </blockquote> {/exp:channel:entries} {/if} {/reverse_related_entries} {/exp:channel:entries} 

Is there a way in ExpressionEngine to insert a couple of tags in a channel within itself?

+7
source share
1 answer

To insert a pair of {exp:channel:entries} tags inside yourself, you need to insert the template into another template using the {embed} variable.

To do this, simply change the tag of the records of the main channel so that it looks like this:

 {exp:channel:entries channel="pages"} {reverse_related_entries sort="desc"} {if show_testimonial} {embed="template_group/template"} {/if} {/reverse_related_entries} {/exp:channel:entries} 

Then create a new template with the contents of a pair of tags of nested channels:

 {exp:channel:entries channel="testimonials" orderby="random" limit="1"} <blockquote> {testimony} <cite> <span class="cite_name">{cite_name}</span><br /> <span class="cite_org">{cite_org}</span><br /> <span class="cite_title">{cite_title}</span> </cite> </blockquote> {/exp:channel:entries} 

What you can include in any ExpressionEngine template using the following syntax, as shown above:

 {embed="template_group/template"} 

Using built-in templates is the standard way for some ExpressionEngine and Parse Order quirks (PDF, 32KB), but they carry a penalty for execution with them, so remember how to choose between {embed} and a {snippet} .

+13
source

All Articles