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.

Conditionals vs Templates for content with same layout

January 18, 2011 1:24pm

Subscribe [3]
  • #1 / Jan 18, 2011 1:24pm

    mailvivo

    4 posts

    We’re in the process of putting together a site that has very similar content (in terms of layout) from one page to another. Thus far, we have used channels to separate out the content and I am now about to code up the template and I’ve been struck by this question:

    What is the templating best route to use when you have similar page content?

    I have seen a number of blogs suggesting that it’s easy enough to achieve by creating different templates (Train-ee tutorial).
    Knowing EE’s ability to use conditional statements to would seem prudent to tell ExpressionEnginge if the URL is “/about” display the ‘About’ channel content and so on. Thus negating the need to multiple templates.

    I realise this may sound like simple question, but I’m pretty new to EE coding, so sorry for my naivety. If the conditional route is the best to go down, what is the best route to achieve this?

    Any assistance/suggestions would be greatly appreciate. Please let me know if I can give more details to clarify.

    Thanks
    George

  • #2 / Jan 19, 2011 1:22am

    John Henry Donovan

    12339 posts

    George,

    would seem prudent to tell ExpressionEnginge if the URL is “/about” display the ‘About’ channel content and so on. Thus negating the need to multiple templates.

    The best route I find is to make separate templates/snippets for your header, navigation etc and embed these which will increase the flexibility of your templates straight away.

    It is possible to wrap channel:entry tags in a conditional testing segments of the URL

    If you set up EE as a local install and install the Agile Theme when installing you will see numerous examples of using embeds and snippets which are very helpful

    Does that help somewhat?

  • #3 / Jan 19, 2011 5:45am

    mailvivo

    4 posts

    Hi Jonh,

    Thanks for the suggestion! You certainly go a fair way to clarifying for me but I’m struggling to implement this. I believe this may be a result of my logic (i.e. first what’s the page URL, then display X content), perhaps I should be doing the opposite (i.e. when content with the url_title tag of X the url will be /X)... if that makes any sense what so ever.
    Would that be a better way to architect this?

    I have already separated the repeated content (held within a ‘Misc’ channel) into embedded templates & this has worked really well.

    As for the main content this will always be held inside the same framework (outlined by the main index file). I have inserted some code to try out your suggestion of using the URL segment tag but when I visit my site’s /about page I still get a 404 error. Here’s a snippet of my (test) code:

    <div class="scrollContainer">
        {if segment_1 == "about"}
        {exp:channel:entries channel="featured_content" disable="categories|member_data|pagination" sort="asc"}
            <div class="panel excess" id="{slide_id}">
                <div class="viewport">
                    <h2>{title}</h2>
    <p>                {page_body}<br />
                </div><br />
            </div><br />
        {/exp:channel:entries}<br />
        {if:else}<br />
        other content<br />
        {/if}<br />
    </div>

    This functions fine in the sense that when I go to my site index page it displays “other content” but clicking on my navigation link to the /about page gives me no joy…

    I presume I’m missing something fundamental here? Any suggestions.

    Once again thanks in advance!

  • #4 / Jan 19, 2011 5:34pm

    Ingmar

    29245 posts

    Properly understanding EE’s URL structure is very important for unlocking its power. Take a look at these articles to get a clearer understanding.

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

ExpressionEngine News!

#eecms, #events, #releases