Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of variables in section settings’ "Template" field (like "Entry URI Format") #5351

Open
benface opened this issue Dec 17, 2019 · 2 comments

Comments

@benface
Copy link
Contributor

@benface benface commented Dec 17, 2019

When creating a Channel or Structure section, it would be useful if we could use variables in the "Template" field(s) below "Site Settings", just like we can in the "Entry URI Format" field(s). For instance, I would like to load a different template based on the entry's type, so I would do it like this:

template

But right now I get the following error message when visiting the URL of an entry in that section:

Template not found: pages/{type.handle}

I know I can achieve the same effect by pointing to a single template that includes a different template based on the entry.type.handle, but I would like to avoid that {% include %} if possible (not sure if it adds any overhead at all, but just from a clean code perspective).

Thanks for considering :)

@brandonkelly

This comment has been minimized.

Copy link
Member

@brandonkelly brandonkelly commented Dec 18, 2019

I’d do this right away, but rendering object templates like those is a little expensive, so not something you want to do on every request. We’d need to start prerendering the templates and storing them for each entry/site when entries are saved. We can look into that when we get to #2450.

@benface

This comment has been minimized.

Copy link
Contributor Author

@benface benface commented Dec 18, 2019

@brandonkelly Makes sense, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.