We make tools that make websites.

Forums (Archived)

The Solspace Support Forums are now CLOSED (read-only)

Check out our new support options here. Please refer to this blog post for more information.

   

Getting around embed’s inside an entries loop

Avatar
RankRank

Total Posts: 79

Joined: Feb 25, 2008

PM

Ignore

 

I have complex entry pages on my site that have embeds inside the entries loop. This allows me to pull in header data and advertisements, etc - without having to insert that into each of my templates. Basically I have it setup similar to this.

{exp:channel:entries ....}
some content
{embed
="header_info"}
some more content 
(BULK of Content)
{embed="advertisement"}
some 
final content here
{
/exp:channel:entries ....

I would really like to get some of the data into Template Morsels, but obviously my embeds are the problem, they wouldn’t parse in TM if I understand correctly. Is it better to leave what I have alone, or could I do something like this below. Which is the better option?

{exp:channel:entries ....}
some content
{
/exp:channel:entries ....}
{embed
="header_info"}
{exp
:template_morsels:fetch name="my_custom_bulk_morsel"}  
{embed
="advertisement"}
{exp
:channel:entries ....}
some 
final content here
{
/exp:channel:entries ....

and then my morsel would of course be:

{exp:channel:entries ....}
some more content 
(BULK of Content)
{/exp:channel:entries ....


Thanks for any clarification on this. I just want to make sure I do this the optimal way on the site. Sometime tells me opening the entries loop more than one time on a single template is going to cause more queries than not, but I may be wrong - that’s why I’m asking the pros.

-John


Edit: I just had one final thought. Is this perhaps another option below? And would it work best, or no?

{exp:template_morsels:fetch name="my_header_morsel"}  
{embed
="header_info"}
{exp
:template_morsels:fetch name="my_custom_bulk_morsel"}  
{embed
="advertisement"}
{exp
:template_morsels:fetch name="my_bottom_morsel"

Each morsel would also have Dynamic Data, not sure if that matters. It would be mainly the URL title.

Avatar
RankRankRankRankRank

Total Posts: 9901

Joined: Jan 8, 2009

PM

Ignore

 

Hi JCDerrick,

Looking at your first code example (with only embeds), why wouldn’t you use {exp:template_morsels:fetch} tags instead of {embed=”“} tags? That’s the goal of Template Morsels: replacing embeds with Template Morsels to speed up your pages wink

The “TM not working in loops” statement is for embed harvesting, not the {exp:template_morsels:fetch} tag. smile

Signature

Avatar
RankRank

Total Posts: 79

Joined: Feb 25, 2008

PM

Ignore

 

You know, that’s a really good point - I’ve been thinking I only should use TM for entries loops, but I guess technically I could put anything inside one.

Can you clarify one thing for me. If I have an embedded template that has another embed inside it (I know, bad practice, but I needed it), will TM render the embedded template or no? How do I go about handling embeds with embeds exactly?

Thanks again,
John

Avatar
RankRankRankRankRank

Total Posts: 9901

Joined: Jan 8, 2009

PM

Ignore

 

I just tested with a morsel containing an embed, and the embed rendered from the morsel grin

Signature

Avatar
RankRank

Total Posts: 79

Joined: Feb 25, 2008

PM

Ignore

 

Awesome, that’s going to be great. I’ll give this a try and see how it turns out for the site. Thanks again Nicolas.