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.

Only one template rest is dynamically embed?

September 15, 2011 8:01am

Subscribe [2]
  • #1 / Sep 15, 2011 8:01am

    amadeus77

    14 posts

    Hi there,

    some very serious questions for me, because I try to build a reusable structure for my work. For Info: I’m working with the file based template option and I’m using the YAML-CSS-Framework also as files (just in the root folder). I want to achieve the following.

    * I want just ONE “main”-template so I can change layout structure, menu elements, JS and other global things in this central file

    * A channel called “includes” with the fields title, file, pagetitle, description, keywords, etc.

    * The main-template holds the whole layout (header, nav, footer, etc) and loads dynamic content based on the URL-segments

    Up to here everything works fine. For example:

    I’m having:

    {exp:channel:entries channel="includes" url_title="{segment_1}"}
    <head>
    <meta name="description" lang="de" content="{description}">
    <meta name="keywords" lang="de" content="{keywords}">
    <title>{site_name} | {pagetitle}</title>
    <link href="css/layout.css" rel="stylesheet" type="text/css"/>
    [removed][removed]
    </head>
    <body>
    <header>
    .
    .
    </header>
    .
    <main>
    {embed="includes/{file}"}
    </main>
    .
    <footer>
    .
    </footer>
    </body>
    {/exp:channel:entries}

    The content loads correctly based on {segment_1} which ouputs the right {file} to load in the embed call but the links to the CSS and JS files are broken.
    But if I use for example
    <link href=”{site_url}css/layout.css” rel=“stylesheet” type=“text/css”/>
    instead the linked files are working correctly.

    So my questions are:

    * In general: Do you recognize wich “one-file”-structure with dynamically loaded embeds I try too achieve? Is it possible an effective how I do it? Are there much more better ways? (The extensions and solutions I found did not really match what i want (e.g. MX Jumper, or the homegrown plugin solution from johndwells)

    * I think the css is not loaded when missing the {site_url} because of the structure that ee normally expects when e.g. {segment_1} is not empty, right? Is there a solution to just force ee to always only load the main index template regardless of the segments - so all the paths in the templates always expects the root folder as starting point? IF yes, are there many ee-properties that will not be usable with my solution all over the whole site then?

    Thank you very much for any help!

  • #2 / Sep 15, 2011 7:10pm

    Dan Decker

    7338 posts

    amadeus77,

    This is a rather unconventional way to use ExpressionEngine. Generally, you control your layouts using templates, which I see you are doing to a degree, and store your content in channels.

    You could use a master template to hold the overall structure. Make embeds for each of your custom layouts, Then you would use different {exp:channel:entries} loops in those embed to pull in your content.

    This question really is more of a how-to and a somewhat out of band one at that. I’ll move this into Community Help to continue the conversation and keep an eye on the progress there.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases