2

Set up your dropdown so that the Option Labels are default, yellow, green, etc. and the Values are page-project, page-project bg-yellow, page-project bg-green, etc. Then, you can {% set bodyClass = entry.backgroundColor %} This will set bodyClass to whatever the value is for the chosen dropdown element, i.e. page-project if you pick the default option.


2

Entry templates are assigned on a per-section basis, and each section can only have a single entry template per site. The workaround is to create a "proxy" template and use that as your section's entry template. The only responsibility for the proxy template is to {% include %} another template (the actual entry template), based on some conditions. ...


1

I found the answer in this thread Dropdown field value getting outputted multiple times The correct syntax to achieve what I am trying to do is: {% if entry.backgroundColor.value == "default" %} {% set bodyClass = "page-project" %} {% elseif entry.backgroundColor.value == "yellow" %} {% set bodyClass = "page-project ...


1

As you noted in your comment, the Twig Perversion plugin will do exactly what you need. It allows you to return a value from a macro, which isn't typically something that Twig permits. Personally, I'd consider it to be fairly safe to rely on this plugin for a few reasons. Marion is a long-standing and trusted developer in the community, the plugin is ...


1

Try inside this in the main template file: {% block access %} {% requireLogin %} {% endblock %}


Only top voted, non community-wiki answers of a minimum length are eligible