Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

Is there a way to have multiple entry templates per entry?

I'd like to create two different templates that display the same content/data in different ways.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

If they can live at different URL's, you could setup multiple routes under Settings->Routes. Give them different URL structures like so:

blog/slug loads mytemplatefolder/blog_template
another-url/slug loads mytemplatefolder/another_template
share|improve this answer
    
Works like a charm, never used routes before. Thanks for the answer! –  Rob Erskine Jul 8 at 12:58
    
Actually, quick followup: I'm getting the following error: Variable "entry" does not exist. When I try and set the variable entry on my own, it's coming up empty: {% set entry = craft.entries.section('brand').slug(slug) %} . Anything special I have to do when using routes to get entry to persist? –  Rob Erskine Jul 8 at 13:28
    
Are you getting the slug from the segment? Like so: {% set pageSlug = craft.request.getSegment(2) %} {% set pageEntry = craft.entries.section('brand').slug(pageSlug).find() %} –  jpea Jul 8 at 13:42
    
Pretty close to what I had, getting a different error now when trying to echo out just the title. {{ pageEntry.title }} gives me a 'Key "title" for array with keys "0" does not exist' error. –  Rob Erskine Jul 8 at 13:57
1  
You still have to do a for loop, even if it's just 1 entry. {% for entry in pageEntry %} {{ entry.title }} {% endfor %} –  jpea Jul 8 at 14:15
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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