1

I've currently got a project on my plate where content is presented in blocks of a few different styles, for instance:

  • A: Introduction area with large graphic, headline, and copy
  • B: Carousel/slider with headline, slides, and copy
  • C: Testimonial block with headline, photo, quote
  • ... and so on.

One page might might call for a layout combination of ABBCBA, another CBBA, and so on. There are a finite number of predetermined combinations.

I'm currently planning on using Blueprints to select the template and manage the publish layouts; the vast majority of pages will live in a single channel. A page with an ABA layout (selected with Blueprints) would utilize the following fields:

Pages Channel

  • Block A1 - Headline (Text)
  • Block A1 - Graphic (Assets)
  • Block A1 - Copy (Wysiwyg)
  • Block B1 - Headline (Text)
  • Block B1 - Slides (Matrix)
  • Block B1 - Copy (Wysiwyg)
  • Block A2 - Headline (Text)
  • Block A2 - Graphic (Assets)
  • Block A2 - Copy (Wysiwyg)

For a page with an ABA layout, I could setup an ABA template, like this:

{embed='blocks/block_a' headline='{block_a1_headline}' graphic='{block_a1_graphic}'}
{embed='blocks/block_b' headline='{block_b1_headline'}' ...}
{embed='blocks/block_a' headline='{block_a5_headline}' graphic='{block_a5_graphic}'}

I've been paying enough attention to chattering within the community to know that including a huge pile of embeds like this is bad news for performance; I'm starting to wrap my head around Stash, but, I haven't seen any examples that appear to relate to the problem I'm trying to solve here.

Bottom line: is there another approach that will work with less overhead, or, is this acceptable, assuming there's adequate caching in place to keep load times snappy?

Could I use a snippet for each block type, and somehow pass the different entry fields to them?

Why not Playa with a channel for each block type? This site will have 150+ pages, each with several blocks that are unique to that page. Managing that many entries would be a huge hassle for content editors.

Why not Content Elements + Mason? We're concerned about multi-lingual and workflow compatibility with Publisher, and possible issues with search.

Your help, suggestions, and feedback will be greatly appreciated. Thank you!

  • So all the fields are contained within the same channel & field group? Is each block of content a entry? For instance, one entry just has block A content filled out? – Siebird Oct 16 '13 at 14:10
  • There will be several channels that utilize the same presentation blocks; each block is not a channel entry. I will edit my question for clarity, thank you for noticing that. – Nick Benson Oct 16 '13 at 14:42
  • So is the layout determined with Blueprints? I'm still confused on how ABA content is parsed? Is ABA content all within the same entry? Would content elements work for this need? Never used it, but seems it might fit the bill. krea.com/content-elements – Siebird Oct 16 '13 at 15:41
  • Each page is a single entry within the Pages channel, and would contain the channel fields as are outlined in the newly edited question above. – Nick Benson Oct 16 '13 at 15:43
1

Nick, in case you missed it, have you considered stash + partials + stash templates.

Ive previously posted some code here. it will give you an idea of the structure.

To set content for your block a,b,c use {exp:stash:set name="block_a"} in your page template.

The template can point to required layout like this {embed="layout/aba"}

In your layout template, add content blocks in required order like this {exp:stash:block_a}

If you have vars to pass, you can use {exp:stash:set_list...

Across your templates, reuse code by using stash templates.

And all this is achieved using a single embed.

And another benefit. You have a layout template abc and it has three blocks a,b,c. Your page template should also set content for blocks a,b,c. If you do not set content for say block b, passing only a,c the layout template will just skip block c and not display anything. That effectively gives you even further freedom to create extra layouts. In other words layout abc can also output combinations of ab or ac or bc.

| improve this answer | |
  • Glanced through the docs, and that looks like an interesting approach; any issues with using the same embed several times, such as a layout for "ABBA"? – Nick Benson Oct 17 '13 at 19:27
  • If {exp:stash:set name="block_a"} is reused in your page template, only the last one is passed. So yes, youll need to modify your naming convention to overcome this – Lloyd Hill Oct 17 '13 at 19:35
  • For abba layout, a and b would need to be set using {exp:stash:set_list name="block_a_list... and {exp:stash:set_list name="block_b_list... – Lloyd Hill Oct 17 '13 at 20:17
1

Mike Boyink has a great write-up on how to achieve something like this using Pixel & Tonic's Playa (which you might be able to do with EE's native Grid fieldtype now). I've used it on several sites myself and found it to be super flexible and useful for the specific situation you're describing.

http://www.train-ee.com/courseware/free-tutorials/comments/flexible-sidebars-using-playa

There's sample code available for download with Mike's article that can help get you up and running quickly (his tutorials are great).

I'd recommend using Switchee to iterate through your Playa field output. This will help keep your query count down and load times reasonable. The template code would look something like this:

{cf_playa_field}
    {exp:switchee variable="{channel_short_name}" parse="inward"}

        {case value="layout_block_a"}
            [ Layout Block A Output] 
        {/case}

        {case value="layout_block_b"}
            [ Layout Block B Output]    
        {/case}

        {case value="layout_block_z"}
            [ Layout Block Z Output]   
        {/case}

    {/exp:switchee}
{/cf_playa_field}
| improve this answer | |
  • I had considered this approach, but opted not to use it, as managing the content in this fashion, on a site as large as this site is going to be (~150 pages, each with several blocks), would be a nightmare. On a smaller project, this would be a completely reasonable approach though, I agree. – Nick Benson Oct 16 '13 at 15:30
1

I would recommend using Stash to do this. I know it takes some getting used to but this is a perfect use case for Stash.

You could also give Content Elements a shot here or use playa and three or more channels.

With Playa channel A1, B1, C1, etc. would be your content channels. They would store your content blocks so A1 might contain your carousel images and captions fields while B1 might contain just your intro paragraphs. Then you would create a channel with a playa field that would let you relate channels A1, B1, C1, etc. and order entries as you want them presented on the page. The new relationships feature in EE2.7+ might also work here but I've found so far that when you need to do something just a little more complex than simple many to many relationships you need Playa.

Content Elements does something similar and with its ability to use other fieldtype add-ons it might fit your need perfectly. It lets users create a block of content from a preset list of content types and drag/drop them to reorder as they see fit.

| improve this answer | |
  • I suspected as much; unfortunately I haven't seen any examples in a similar application, or had a lightbulb moment whilst reviewing the articles/podcasts I've heard on the topic. – Nick Benson Oct 16 '13 at 14:43
  • Both of those are good solutions that probably wont't work in this case, unfortunately. I looked at using Content Elements and Mason to accomplish this (it would have been perfect), but, there were concerns over search and making it multi-lingual with Publisher. Playa with channels for each block was also considered, but at the scale of this site (~150 pages) it would be problematic from a content editor point of view. – Nick Benson Oct 16 '13 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.