Hot answers tagged

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

You probably have a misconfiguration in your environment variables - First go to the control panel and check what you have under Settings > Sites > [choose site] > Base URL. If it's set to an env variable (i.e. it begins with a dollar sign), go to wherever you store your environment variables (e.g. the .env file, or maybe server env vars if you're ...


2

To only disable an entry, use this: If entries need to be deleted, you can create a custom plugin, where entries will be deleted when expired or when the postdate is older than 2 weeks..


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

To anyone else that needs to something similar: {% set query = { section: 'case_studies', limit: entry_limit, orderBy: 'featured desc, postDate desc', }%} The pagination is wonky without the secondary orderBy parameter. I'm guessing it's because the field for an inactive lightswitch is empty in the DB? I'm speculating, but prior to adding that it ...


1

You can add an orderBy clause to the query, and order by the lightswitch field. For example, to fetch all the entries in section things, with the ones with the featured lightswitch turned on first, do this: {% set things = craft.entries({ section: 'things', orderBy: 'featured desc' }).all %}


1

You're looking for the filter filter. Here's how you might do it: {% set entriesInCat = craft.entries.relatedTo(category).all() %} {% set featuredEntriesInCat = entriesInCat|filter(entry => entry.yourLightswitchFieldHandle) %} {% set remainder = entriesInCat|without(featuredEntriesInCat) %} {% for item in featuredEntriesInCat %} <h2>{{ item....


1

You are setting variables within the scope of the for loop – they only exist there. You can fix this by setting up empty variables before the loop, like: {% set webinar = block.webinar.all() %} {% if webinar is not empty %} {% for entry in webinar %} {# Setup empty variables #} {% set name = null %} {% set avatar = null %} ...


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