All Questions

Tagged with
Filter by
Sorted by
Tagged with
1
vote
1answer
1k views

Set a Variable inside a conditional

I'm building my first Craft site and need to set a variable if a field has an image and then use that variable elsewhere in the template. The field is part of a matrix and will repeat. What I have ...
2
votes
2answers
177 views

Are there any tradeoffs if you use the null-coalescing operator in place of first()?

With the addition of the null-coalescing operator (??) in Twig, it now appears that the following two examples both provide a way to retrieve the first entry and fallback to null if no entry exists: {...
1
vote
2answers
969 views

Conditional logic to add class for specific section entries

I'm trying to create a conditional logic so that the class 'white-nav-bg' is added to the element on the 'blog' section entries only. Below is the code I'm currently using to try and achieve this ...
2
votes
2answers
2k views

Conditional Logic to show or hide fields in the admin?

I'm looking for a way to show or hide fields when editing an entry based on items selected. I need to manage a list of businesses and my plan is to have a channel to hold them all. But based on the ...
2
votes
1answer
700 views

Return entries with startDate or endDate within a calendar year

I have two date fields in my entry and I want to return those entries with either a start date OR and end date within a calendar year. I can get those with a startDate within the calendar year using: ...
2
votes
1answer
86 views

How do I add a second section name to this logic?

I need to add a second section name to this code: craft.entries.section('not homePage') I can't figure out the correct formatting. I've tried: craft.entries.section('not homePage,clientPage') craft....