ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Embed Templates? One Template per one static page??

April 27, 2011 12:55pm

Subscribe [2]
  • #1 / Apr 27, 2011 12:55pm

    rwoodlevlane

    11 posts

    Hi. Two weeks into EE I now realize the many ways to configure EE to handle what ultimately appears as static pages.

    That being said I am still curious about the initial mission, or the native handling of EE as suggested within the overview section of the user guide:

    “...Usually, each of your Templates will represent an entire web page, although it is possible to embed templates within other templates if you want to use common site elements in all your pages, like headers or footers…”

    Is this practice used anymore? It seems that one could simply make ONE template, and for reusability, can treat snippets as includes files whereby the header and footer could simply reside as a snippet.

    The template can then call in the dynamic body content per entry, for example {body_content_from_each_entry}

    I am confused as to why anyone would require to embed a template within a template, and in all of my research and partnering up on a few EE run sites, have not seen this practice.

    Please advise.
    Thanks!
    Rich
    ps…really digging EE.

  • #2 / Apr 27, 2011 1:33pm

    vosSavant

    380 posts

    There is absolutely a reason to use embeds, and I use them often, generally in the following two scenarios:

    1. I need to pass variables (for instance, a page title or body ID to an embedded header)
    2. I need to nest a query within another query

    Here is what the EE docs say regarding the difference between embeds and snippets:

    “Snippets can be considered to actually be part of the template that they are used on, with their expanded contents parsed simultaneous to other tags and variables on the template. Embedded templates are separate templates, with their own preferences (caching, PHP parsing, access, etc.), and are parsed individually. Put another way, embedded templates are not included in the parent template, but rather added to them after the fact, using a separate query and full page parsing resources for each template.”

    Lisa has a better explanation here.

    Hope that helps!

  • #3 / Apr 27, 2011 2:35pm

    rwoodlevlane

    11 posts

    Oh very cool! I see.
    It’s mainly about order of execution.
    I found some nice articles and charts floating around online about various components for EE (URL usage, tag reference charts, etc)
    Would you happen to know of a resource for order of execution regarding which elements are parsed in which order?
    The topic of how the pages are parsed seems to be one that would prove very helpful in controlling content as well as utilizing the various components within EE.

    Also if a site utilizes template groups and templates and templates, embedded in a template…and finally…entries - how would one address a “page” within the URL or URI?

    For example, the user guide talks about templates. To address your pages, one would use domain/template-group/template

    I did not see it address the ENTRY

    so would it be domain/template-group/template (with the template embedded)/entry?

    If so, how do we access the entry?

    Thanks!
    Rich

  • #4 / Apr 27, 2011 3:27pm

    vosSavant

    380 posts

    Hey Rich,

    Great question on parse order. There’s an article in the wiki on that.

    You’ve got it with the URLs:

    <a href="http://domain.com/index.php/&#91template_group&#93/&#91template&#93/&#91entry&#93">http://domain.com/index.php/[template_group]/[template]/[entry&#93</a>;

    Embedded templates do not appear in the URL; rather, the template calling the embed appears in the URL. For instance, I always have an includes/header template, which is embedded in everything, but the “includes/header” will never appear in the URL.

  • #5 / Apr 27, 2011 3:32pm

    rwoodlevlane

    11 posts

    Totally makes sense!
    Richie is very happy 😊
    Thanks a ton for your help.
    The beginning hurdles are JUST about over for EE for me.
    Yaayyy!
    Thanks again
    Rich

  • #6 / Apr 27, 2011 6:07pm

    vosSavant

    380 posts

    Glad I could help. Have fun!

  • #7 / Apr 28, 2011 5:20am

    John Henry Donovan

    12339 posts

    Thanks Ryan. Another Parse Order resource here.
    Closing this one. Feel free Richie to start a new thread if you have any more questions

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases