Thread tagged as: Problem

List / Detail pages - more than one template to choose from?

Is possible to have more than one template for list/detail pages?

My clients site uses list/detail pages for one section and all projects use the same layout apart from one which needs to be different. I'm trying to figure out how to incorporate it and wondered if I can create a specific set of templates for it and still have appear within the list page among the other projects.

Is this possible?

A workaround I suppose is to have it right at the bottom of the page and hard-code the list element into the page and have the detail page link to actual html pages. It's a project that doesn't require editing anymore and just needs to be included and it would be great to be able to slot it in the timeline of projects as they're all in chronological order, so having it at the bottom would be a bit weird, but happy to settle for that if it's the only option.

thanks Evie

Evie Milo

Evie Milo 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Add a field to indicate which template to use.

Then use a perch:if to check that field and branch your template into two sections.

Thanks Drew - client doesn't fancy re-entering all the content via CMS as there's loads, and neither do I now, so i think we're going to go for the hard coded option. Nice to know that it is possible though.

So with this perch:if option would there be a way for the client to choose which template to use in the cms?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, add a select field with the options.

I need to know how to do this now as another issue has come up on the site I've just put live. I use list/detail method for a poem archive and all the poems on the site so far have always been left aligned. A new one has come up which has be have centered text and so I want to duplicate the existing template and rework the text alignement (everything else would be the same) and I want to offer my client the option to select which template to use, the default left aligned on oe the new centered text one.

Can you let me know if there's a tutorial to follow or where I can find the relevant info in your knowledgebase as I've had a quick look/search but not found anything, mostly down to the fact I've not got the right search terms probably.



Drew McLellan

Drew McLellan 2638 points
Perch Support

If it's just changing the text alignment, do you really need a different template? Could you not just do with a class on the container?

<div class="<perch:content id="alignment" type="select" options="Left|poem-left,Centre|poem-center,Right|poem-right" label="Text alignment" />">
   ... your poem fields ...

And then in your CSS

.poem-left { text-align: left; }
.poem-center { text-align: center; }
.poem-right { text-align: right; }

There's a smple workaround that might just do the trick - I'll look into it and have a go soon as the cklient has chnged her mind and the idea has been shelved for the time being due to other commitments, but it's something that will be implemented soon I hope. I thought using a seprate template would be best as I don't want the existing content on the site affected, plus I'm no CMS or PHP expert and so often don't see that there's a simple way to do things and presume everything is excessively complicated.