Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

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

Closed
benface opened this issue Dec 17, 2019 · 2 comments
Labels
enhancement improvements to existing features site development 👩‍💻 features related to website/API development

Comments

@benface
Copy link
Contributor

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 brandonkelly added enhancement improvements to existing features site development 👩‍💻 features related to website/API development labels Dec 18, 2019
@brandonkelly
Copy link
Member

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
Copy link
Contributor Author

benface commented Dec 18, 2019

@brandonkelly Makes sense, thanks!

@benface benface changed the title Allow use of variables in section settings’ "Template" field (like "Entry URI Format") [Feature Request] Allow use of variables in section settings’ "Template" field (like "Entry URI Format") Mar 20, 2020
@craftcms craftcms locked and limited conversation to collaborators Jun 22, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement improvements to existing features site development 👩‍💻 features related to website/API development
Projects
None yet
Development

No branches or pull requests

2 participants