Forum

Thread tagged as: Question, Problem, Suggestions

Different templates for multiple region items?

Is there a way for the user to assign different templates to the various sub regions?

I have come across a problem in my code, where various sections and pieces of content is presented in a 'draggable' carousel slider. The visitor is presented with one slide at a time, and can drag between the different sections.

Now, the client wishes these sections to be flexible both in number, and in type. So for instance, he wishes to have a template for a contact section, a template with an image and text, and so on and on.

The following piece of code works great, except for the fact that all the sub regions now share the same template. This means, there can only be one type of content for every slide. It becomes a compromise between giving the client the power to add more slides, or to add different kinds of content.

<?php perch_content_create( 'Slider_content', array(
    'template'   => 'slide.html',
'multiple'    => true,
'edit-mode' => 'list detail',
));?>

I have tried to put all the different use cases in the 'slide.html' template, but now it has grown so huge and complicated, full of if's and else's, multiple checkboxes and the like - that I simply can't cram any more into it, nor would I want to.

I could of course hard code another region in, say called 'Slider_content_last'. I could then assign the contact template to this last slide - but this severely limits the use of a cms in the first place, and now the client will have multiple regions that actually are the 'same' region, creating confusion.

Ideally, I would want them to be able to change to different templates for the individual sub regions, from the admin area.

If I have overlooked something here, or there is some other workaround, I would very much appreciate it!

Thanks!

Jarl Robert Kristiansen

Jarl Robert Kristiansen 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

By "sub regions" do you mean items within a multiple item region? Or Repeaters? Or something else?

Yes, I meant Items within a multiple item region, sorry for the confusion.

Repeater's can only be used inside a template right?

Basically I just need some sort of repeated 'region' or whatever you want to call it, where the items can be assigned different templates, but still belong to the same 'region' if you understand me. So one 'region' would be 'Groceries'. Another 'Hardware'. But within 'Groceries' and 'Hardware', you could have different sub templates, for instance 'Screws' and 'Greens'. Hope this makes sense :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

Perch doesn't offer that.

That's too bad, I have really fallen in love with Perch. Hopefully this is something that will come further down the line.

Thank you for your excellent support, much appreciated.