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.

Client ability to choose template

December 25, 2009 2:18am

Subscribe [4]
  • #1 / Dec 25, 2009 2:18am

    webdezzo

    16 posts

    Hey all,

    How would you give the client the ability to choose from multiple templates (2-column, 3-column with an image etc) and have different data field sets that go along with each template?  So, my 2 column layout has a large header image at the top, and my 3 column layout has 3 small images with text in each column.  When the client adds a page - if it’s a 2 column layout needs to be able to add the 1 big header image plus 2 unique text areas.  If it’s a 3 column layout needs to add 3 images and 3 text areas. 

    Twist: Can this be done within one channel?  I would really like it to all be within the pages module channel.

    Best way to do this?  Do I have to create 2 separate channels using 2 custom field sets?  The main thing I want to retain is the pages module functionality where all of the pages would be accessed via:

    http://www.domain.com/my-pages-uri/

    but using different templates.  But I don’t want to create custom fields for every possible data type and confuse the user.  I don’t think they should have to know, “I need to fill in this data because I am going to use 2 column layout, and I need to fill in this other data because I am using column 3 layout”.

    Any help / explanations or better ways to do this would be greatly appreciated!

  • #2 / Dec 26, 2009 10:39am

    Rob Allen

    3114 posts

    Using the Pages module you can select a template to use (it’s just under where the pages uri is added). However, this will show all your templates so may not be practical.

    What I’d probably do is run your “pages” as normal channel/weblog entries without using the Pages module. You’d have to display all possible custom fields that could be used on a page though - let’s face it, the client might want to later change a 2 column to 3 column or vice versa?

    The key to choosing a template to use would be to use a custom select field which has the template options, ie “template1 and “template2”. Then in your “page” template use some conditionals to show data accordingly:

    {if custom_field == "template1"}
    {custom_field1}
    {custom_field2}
    {/if}
    
    {if custom_field == "template2"}
    {custom_field1}
    {custom_field2}
    {custom_field3}
    {custom_field4}
    {/if}

    Get the idea?

  • #3 / Dec 26, 2009 11:20pm

    ChiefAlchemist

    913 posts

    Are they adding pages or adding content? Let me example… 

    I guess what I’m asking/suggesting is that when the content is entered, the “template” type would be selected. It could even be a category. Then when the content is pulled (read: Select) from the weblog the template_type would be evaluated and the correct type of page rendered with that content wrapped within it.

    Or did I just read your post all the wrong way?

  • #4 / Dec 27, 2009 6:52pm

    webdezzo

    16 posts

    Well, they would be adding pages, but not all pages would look exactly the same.  They may add a page that has 2 columns with a big header image, or they may add a page that has 3 columns with 3 small column header images.  The choice would be up to them.

    But currently - using the pages module, you would just have 1 channel to support it.  But you would have to account for all of the data fields for every possible template type.  Here would be a list of custom fields I would need to have currently to support 2 template types

    Template 1 - 2 column with large header image
    Template 2 - 3 column with 3 small column header images

    Fields:
    - 2 column large header image
    - 2 column left column text
    - 2 column right column text
    - 3 column left column header image
    - 3 column left column text
    - 3 column middle column header image
    - 3 column middle column text
    - 3 column right column header image
    - 3 column right column text

    The user would have to see all of these custom fields on the single page entry view - and they will more than likely end up adding text to the wrong fields - and images to the wrong associated images.

    It would be really nice to somehow create a work flow where the user chooses the 2 column template, and is then presented with only the 2 column template fields:
    - 2 column large header image
    - 2 column left column text
    - 2 column right column text

  • #5 / Dec 27, 2009 11:47pm

    JArment

    131 posts

    This is one thing I’d like to see extended some day - where you could have a question at the top and based on what they chose particular custom fields would be available. I haven’t seen anythign that accomplishes this, but I’ve done something that might work for you (if you don’t mind using FieldFrame and FF Matrix).

    Create two custom fields and make them both FF Matrix. Then for the field names, ask a question or direct your user. (e.g. Do you want a 2-column page? or Use this to create a 2-column page.) You can add all the fields you listed above with an FF Matrix and limit the the “max rows” to “1”.

    Then the trick is to set “Show this field by default?” to “No”. SO when your user goes to publish, there are the two question and an option to expand each one.

    I had great feedback and results when I implemented this for my church. I use it for an event channel. And ask the following three questions: (1) Does this event need it’s own page? (2) Do you want to link to a related website? And (3) Registration Form for this Event?

  • #6 / Dec 28, 2009 10:52am

    ChiefAlchemist

    913 posts

    Good morning gents…

    Let me just follow up by saying that I have not yet used the Pages module. I suppose I should check it out but the primary reason I moved to a CMS was to get away from static pages.

    Moving right along…

    I asked: “Are they adding pages or adding content?” I was being somewhat rhetorical, pardon me. IMHO, they are adding content. Then different prices of content are pulled together to present a page. I would presume that some content spans multiple pages. For example, and upcoming event announcement might be on 3 or 4 pages. The idea you propose makes it sound like each page is separate. In other words, the user has to enter the same event multiple times. Correct? (Sounds “ugly”.)

    True, the site will have to define pages @ some point. But that could be (or should be?) separate of the content. No?

    Moi? I’d break it all down into pieces of content - not pages. And then have you (or the user define) what content goes where on each layout. And then pull the pages together on the fly. In you case it sounds like there’s a primary piece of content and that’s where the layout can be selected.

    Something like that 😊

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

ExpressionEngine News!

#eecms, #events, #releases