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.

Two different single entry view templates, same channel....

October 22, 2012 10:04am

Subscribe [2]
  • #1 / Oct 22, 2012 10:04am

    shorn

    79 posts

    Hi all, just looking for a bit of a nudge in the right direction.

    I have a news section on my site, (entries in news channel).

    I have a single entry view template. It is a main/left sidebar layout.

    For some entries in this channel, I would like it to have a different layout (full width for example)

    Whats the best way to go about this?

  • #2 / Oct 22, 2012 10:44am

    Boyink!

    5011 posts

    One thought is to put a custom field in the channel - just a drop/down maybe with yes or no values.  Then in your template code use it’s value in a conditional to return the sidebar HTML.

    Granted it’s not two different templates but rather one template with different HTML but maybe might work?  It would mean the HTML would need to degrade gracefully but would keep your URLs consistent no matter the layout.

  • #3 / Oct 22, 2012 1:47pm

    shorn

    79 posts

    Ah great, that’s kind of what I was thinking.

    Template will obviously need a bit more planning, but would be worth it to keep things simple.

    Out of curiosity, do you think it would be OK to change the whole template section based on the conditional, or should I break it down further?

    ie. I could have something like:

    HEADER

    IF"YES”

    BODY TEMPLATE 1

    IF “NO”

    BODY TEMPLATE 2

    FOOTER

    That should work, right?

  • #4 / Oct 22, 2012 1:49pm

    Boyink!

    5011 posts

    Yes.

  • #5 / Oct 22, 2012 1:53pm

    shorn

    79 posts

    Great, thanks for your help. Much appreciated.

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

ExpressionEngine News!

#eecms, #events, #releases