1

I'm using this support article as a guide and I'm stuck on what I'm doing wrong.

I have an "events" section, and I would like to use a different template for one the entries. I've created a new entry type in the "events" section and gave it the handle "summerpreview." I created a template in the "events" subfolder: "_types" entitled: "summerpreview.html." That template uses the include tag:

{% include "events/_types/" ~ summerpreview.html %}

I've created an entry inside the "events" section using the "summer preview" entry type and gave it the slug of "summerpreview."

What am I missing here? The entry pulls using the default "events" template and not the "summerpreview." What do I need to do for this event to use "summerpreview" template?

3

You need to allow the entry.type value to be part of the include path...

{% include "events/_types/" ~ entry.type %}

Since your entry.type is "summerpreview", that will be parsed out like this...

{% include "events/_types/summerpreview" %}

With Craft, you don't need to specify the .html extension, so this include should work perfectly.


As a side note... I'd recommend turning on devMode locally. It would have thrown an error, telling you that summerpreview is not a legitimate variable.

What Dev Mode Does

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.