craft3-templateselect icon indicating copy to clipboard operation
craft3-templateselect copied to clipboard

FR: Template subfolder variable

Open richhayler opened this issue 7 years ago • 1 comments

Could you please add the option to output the selected template's full path or subfolder so in a front end template this doesn't have to be hardcoded?

so instead of {% include '_mysubfolder/' ~ entry.template %}

maybe {% set template = entry.template %} then {% include template.filepath %} or {% include template.subfolder ~ template %}

richhayler avatar Apr 10 '18 11:04 richhayler

Big upvote for this.

Another option would to allow the subfolder to be set via a .env variable.

Application Info PHP version | 8.0.8 MySQL 8.0.27 Craft Pro 3.7.31 Yii version 2.0.44 Twig version v2.14.11 Template Select 2.0.2

anchovy avatar Feb 28 '22 21:02 anchovy

This is now available with v5.0.0.

These are the different options now:

Output the chosen template name:

{{ entry.fieldHandle }}

Include/Embed the chosen template:

{% include entry.fieldHandle %}

Include the template including subfolder if set:

{% include entry.fieldHandle.withSubfolder() %}

This is a alias for the following:

{{ entry.templateWithSubfolder.template(true) }}

Output the subfolder name:

{{ entry.fieldHandle.subfolder() }}

Output the filename without path:

{{ entry.fieldHandle.filename() }}

sjelfull avatar May 12 '24 20:05 sjelfull