3

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.

1 Answer 1

4

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
5
  • Works like a charm, never used routes before. Thanks for the answer! Commented Jul 8, 2014 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? Commented Jul 8, 2014 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
    Commented Jul 8, 2014 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. Commented Jul 8, 2014 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
    Commented Jul 8, 2014 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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