1

Since Layout templates are so handy (cutting the template into interchangeable header/sidebar/footer, etc), why should our use an embed tag? Any ideas on when you should not use an embed tag over a layout tag?

1

One simple difference is that you can use only 1 layout template to do what takes at least 2 embeds to be done: header and footer code sections. Every template parsing you save counts.

You can use embeds for several things:

  • to nest the same module inside itself or modules which have conflicting variables inside each other, because this can cause serious conflicts on the same template. Like a exp:channel:entries tag inside another one or a exp:comment:entries inside a exp:channel:entries;
  • to have a different template cache time on an embed from the template it's loaded;
  • to have similar templates loading at different URLs, if you are too scared of routes. Something like /cars and /boats loading the same template;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.