1

If I have a Section called "Pages" that uses the "page.html" Entry Template.

How do I override that template for a single page in this Section?

I thought I would be able to use Craft Routing but the Entry request (#4) is picked up before the Dynamic Routes (#5).

Is there a nicer solution to this rather than a bunch of if statements in the template?

{% if craft.request.getPath() == "about" %}

    {% include '_includes/about.html' %}

{% endif %}

I also found this solution, but not sure if it's overkill if I only want to override 1 Entry?

  • 3
    It's not overkill, that's exactly the right solution. – Lindsey D May 30 '16 at 6:37
2

Zuccs, have a look at this plugin: https://straightupcraft.com/craft-plugins/template-select

1

Hey @zuccs you should look into Entry Types

https://craftcms.com/support/entry-type-templates

1

Ultimately, you would want to create a single for this type of situation. There are differences in the entry types.

Structures - These are for hierarchical pages, pages that should be displayed in a specific hierarchy and order.

Channels - These are used when you have a set of pages that fit within a parent but do not need to be in a specific order. For example, a products parent page with 10 product entries within. It wouldn't matter which order the products are in within the channel because you can sort them however you would like.

Singles - singles are one off pages for exactly what you are looking to do. Singles are cool for say the Home page or a one off Contact Page or About Page if there are no sub pages.

The nice thing about craft is you can pretty much use whatever you want. I'm not sure how your structure works but I believe having a single would be better in your situation. There are quirky workarounds and routing plugins you can use to do what you are trying to accomplish, but better organization with your structures, channels and singles would be the best overall solution.

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.