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.

Content layout variations — best practice?

October 08, 2010 7:43am

Subscribe [3]
  • #1 / Oct 08, 2010 7:43am

    Wayne Smallman

    176 posts

    Hi guys!

    I’m working on a website at the minute, which needs multiple layouts. So far, I’ve cobbled together something that works, but isn’t optimal.

    I’m using Snippets to contain the HTML for the layouts, which are then selected from a drop-down (select) field in the Entries editor. The problem is, the drop-down is the major weak point, in that there’s no option to add a value and name. So I can’t place a descriptive title into the drop-down items.

    The client and the designer will be have access to ExpressionEngine at some point and the layout selector has to be obvious and easy to follow. Right now, it’s not.

    So does anyone have any suggestions for a better way of accomplishing this?

  • #2 / Oct 08, 2010 10:18am

    ender

    1644 posts

    The select dropdown fieldtype available for EE 2 in the P&T field pack and for EE 1 in FieldFrame offers the ability to specify the value and label separately.

  • #3 / Oct 08, 2010 10:35am

    Wayne Smallman

    176 posts

    Ender, thanks!

    I will look into that, because it looks useful. But that’s not the real issue as such; I need to know if there’s a smarter way to handle layout styles other than conditional statements.

  • #4 / Oct 08, 2010 5:25pm

    ender

    1644 posts

    don’t know anything about the site or content, but you could use the pages module to let the client pick which template to use and fill in their own URI using the pages module.  you’d just need to code up templates for all the layout possibilities.

  • #5 / Nov 27, 2010 2:05am

    vacquah

    355 posts

    Hi guys!

    I’m working on a website at the minute, which needs multiple layouts. So far, I’ve cobbled together something that works, but isn’t optimal.

    I’m using Snippets to contain the HTML for the layouts, which are then selected from a drop-down (select) field in the Entries editor. The problem is, the drop-down is the major weak point, in that there’s no option to add a value and name. So I can’t place a descriptive title into the drop-down items.

    The client and the designer will be have access to ExpressionEngine at some point and the layout selector has to be obvious and easy to follow. Right now, it’s not.

    So does anyone have any suggestions for a better way of accomplishing this?

    HI - Wondering if you can share your methodology. I am trying to do the same thing ( using custom templates per entry - but not pages module). - See my post here:  http://ellislab.com/forums/viewthread/174455/

    I am currently building the html snippet for each template. I have also added it to the entry page , where i can specify the name of the snippet for the entry.  My problem is how to dynamically call the snippet name on the main template ( outside of the channel tag). how are you doing this?  ( I thought adding the snippet as a select field in an entry forces you to output it in expressionegine tags? I am trying to do something like this:

    {embed="embeds/html_header"  url_title="{segment_3}"  title="Our Photo Stories"}
    {embed="custom_stylesheets/stories_01"}
    {embed="embeds/_scripts"}
    
    
    </head>
    
        <body id="stories_main" class="page">
             output selected snippet name here - note that there is no ee tag here
        </body>
        
    </html>
  • #6 / Nov 27, 2010 8:02am

    Boyink!

    5011 posts

    IMHO conditionals are perfect for this.  What’s the reluctance to use them?

  • #7 / Nov 27, 2010 1:18pm

    vacquah

    355 posts

    IMHO conditionals are perfect for this.  What’s the reluctance to use them?

    Not reluctant to use conditionals - just not sure if its scalable enough to apply to a lot of custom templates. Assuming I use a custom template for each of my single entry pages going forward, I would want to implement something that simply allows me to select the template name and css file on the entry publish screen.  I looked at a few plugins last night - String, Template & Snippets e.t.c - I still couldn’t figure out how to call and apply a whole template to the entry ( much like what the Pages module does but dynamically).

  • #8 / Nov 27, 2010 3:16pm

    Boyink!

    5011 posts

    Boy you have way more energy than most…just coming up with unique content is enough and you’re throwing in design as well? 😉

    A couple of thoughts:

    - Why not just put the HTML in the entry with the content?  If it’s all related this might make sense.  I’m not sure how much your layouts will vary but if you are using a CMS at all there must be some limit to how much the content structure can vary within the design.

    - Alternatively why not per-entry templates? If your content structure is going to stay the same this might in the end be easier than a per-entry snippet approach. You could still use EE tags to build navigation dynamically so long as you keep the url_title of an entry the same as the template that it’s designed to be presented through.  With this approach the index template of a template group could be the “fall-back” - something to present the content in if there isn’t a specific template for it.

    - Your requirements do remind me of http://devot-ee.com/add-ons/blueprints/ - but that’s designed for use with Structure, and I’m not sure if it would scale to a per-entry layout.

    But keep in mind you are pushing EE in a direction that it’s really not inherently designed to go. For the vast majority of users pushing content through standardized templates is the major draw of a tool like ExpressionEngine.  At some point for you I wonder if using EE is going to actually be more difficult than a more page/HTML centric CMS.

  • #9 / Nov 27, 2010 3:21pm

    Boyink!

    5011 posts

    Another good resource might be Greg Wood’s Editorial Design with ExpressionEngine presentation from last years EECI.

    In it Greg showed how he allowed a variety of editorial layout decisions by adding a number of custom fields and conditionals within templates.

  • #10 / Nov 27, 2010 3:40pm

    vacquah

    355 posts

    Boy you have way more energy than most…just coming up with unique content is enough and you’re throwing in design as well? 😉

    - Alternatively why not per-entry templates? If your content structure is going to stay the same this might in the end be easier than a per-entry snippet approach. You could still use EE tags to build navigation dynamically so long as you keep the url_title of an entry the same as the template that it’s designed to be presented through.  With this approach the index template of a template group could be the “fall-back” - something to present the content in if there isn’t a specific template for it.

    ha! Just using this to experiment with custom designs. The concept of having a unique design per entry to tell a story ( photos and video ) is very appealing to me! I won’t do this every day, but when time allows! 

    I have also seen the presentation by Greg Wood - Its more of a tut on grid based designs, no?  ( I don’t see the part about ee conditionals in the presentation)

    Finally, your idea about using page specific template might be the way to go - but boy, it will be sooo much easier to have just one template and dynamically change the innards to suit. For instance I have looked at this right now:

    <body id="stories_main" class="page">
        {embed="custom_templates/stories_01"}
        </body>


    here, I directly typed in the template name - the missing ah ha moment for me is how to specify “custom_templates/stories_01” dynamically through the entry publish page. then I will be good to go!

  • #11 / Nov 27, 2010 3:50pm

    vacquah

    355 posts

    the per entry template approach can also build up a lot of templates very quickly, no?

  • #12 / Nov 27, 2010 4:13pm

    Boyink!

    5011 posts

    Well, yes, but at the same rate as a snippets-based approach would..😉

    Yea -as I looked at Greg’s slides I didn’t see the EE code, but I do remember him talking about it.  Essentially he’s just creating EE custom fields that allow a options (alignments, colors, font-faces etc) that get fed through to the HTML to vary the design.

    If you are back at needing visibility of template names on the Publish page I see only two options:

    1. Create a custom extension that would pull all template names (or snippet names) or,

    2:
    - Create a channel just to store the template names. Create a custom field where you enter valid template names (ie “template_name”).
    - Create a new custom field in your main publishing channel, specify a drop-down field type, then choose the “Populate the menu from another custom field”.  Choose the channel and field you just created in the previous step.
    - In your template code now feed the value of this custom field into your embed statement (this would need to be in a channel:entries loop):

    {embed="custom_templates/{template_name}"}

    This latter approach will require you to publish a new entry for every new layout/template - but might work?

    You could wrap it in a conditional that checks to see if a value has been chosen, and if not pass the embed off to a generic/default layout.

  • #13 / Nov 27, 2010 4:58pm

    vacquah

    355 posts

    1. Create a custom extension that would pull all template names (or snippet names) or,

    There is one out just for this! - Template and Snippet Select.  it actually allows you to see a dropdown list of all templates and/or snippets for selection!  Seems like the perfect solution, however, I can’t get it to work in an embed outside of the channel entry tag. So I actually implemented it and tried the code below - no luck. I suspect it has to be wrapped in an ee tag.  ( I set the name of the selection field in the extension as “template_name”, then selected a specific template for each entry on the publish page)

    <body id="stories_main" class="page">
        {embed="custom_templates/{template_name}"}
        </body>


    Looking into your second proposition now ..... looks promising. Don’t mind the extra step of creating an extra entry for the template name.  Is there any performance hit with this methodology?

  • #14 / Nov 27, 2010 5:44pm

    vacquah

    355 posts

    2:
    - Create a channel just to store the template names. Create a custom field where you enter valid template names (ie “template_name”).
    - Create a new custom field in your main publishing channel, specify a drop-down field type, then choose the “Populate the menu from another custom field”.  Choose the channel and field you just created in the previous step.
    - In your template code now feed the value of this custom field into your embed statement (this would need to be in a channel:entries loop):

    {embed="custom_templates/{template_name}"}

    This latter approach will require you to publish a new entry for every new layout/template - but might work?

    You could wrap it in a conditional that checks to see if a value has been chosen, and if not pass the embed off to a generic/default layout.

    is this different from just creating a new custom field ( text entry) in the main publishing channel where i can input the name of the template?  I tried that and it didnt work. 

    {embed="custom_templates/{template name entered in text field area}"}
  • #15 / Nov 27, 2010 5:50pm

    Boyink!

    5011 posts

    Yes- this code needs to be inside an entries tag - otherwise you have no access to the values in you custom fields n

    Mainly the same idea as a text field. Ive used this approach elsewhere so it will work- might just have to finess the code a bit.

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

ExpressionEngine News!

#eecms, #events, #releases