2

You could do something like this: {# Fetch entries + authors and group by author id #} {% set entriesByAuthors = craft .entries() .section('itbuzz') .limit(null) .with('author') .all() | group(e => e.author.id) %} {# Build an array with authorId and entry count for each that we can sort them #} {% set leaderBoard = [] %} {% for ...


2

If I'm following you, arrays are 0-indexed, so this would work (with a bit of cleanup). {% set names = 'first-last'|split('-') %} {% set firstNameSlug = names[0] %} {% set lastNameSlug = names[1] %} {{ firstNameSlug }} {{ lastNameSlug }}


2

You could eager load a little more to speed things up. Especially your eventVenueName and eventCity For your query, try: {% set entries = craft.entries ({ section: 'events', limit: '30', order: 'postDate desc', with: [ 'eventMediaTile', 'eventVenueName', 'eventCity' ], ...


2

It’s possible to do this by making the entire CSS file a Twig template. Create a new file in your templates folder, such as templates/css/styles.css, with all the dynamic styles you want. To prevent the browser from reloading the file on each request, make sure you set cache headers in the template. {# Tell the browser to cache this page for 30 days #} {% ...


2

An empty date field will return null. Your conditional is slightly off as you have an elseif straight after your first if. Try: {% if entry.eventStartDate is empty %} There is no date set. {% elseif entry.eventStartDate > now %} There is a date and it's greater than now. {% elseif entry.eventStartDate < now %} There is a date and it's ...


2

It may not be suitable for your use case but you could use an Asset query to fetch assets related to your entry: {% set assets = craft .assets() .withTransforms(['eventImage']) .relatedTo({ sourceElement: entry, field: ['your','fields'] }) .all() %} {% for asset in assets %} ... {% endfor %} (If these are your only ...


2

You're always getting the same set because the entries are first fetched, then shuffled. To achieve what you want, you could do: {# get all your entries ids #} {% set allIds = craft.entries().section('yourSection').ids() %} {# Shuffle all and slice to just 15 #} {% set shuffledIds = shuffle(allIds) | slice(0,15) %} {# Fetch your random entries #} {% set ...


1

It feels like not all your products have a fieldPropertiesCategory value defined. Does that work? {% set products = craft.entries.descendantOf(entry).all() %} {% for product in products %} {% set properties = product.fieldPropertiesCategory.one() %} {{ properties ? properties.propCatFieldColor : '' }} {% endfor %}


1

Well. It's not pretty but it works. That improvements could be made on this is both certain and welcome. {# Check to see if we've for got prices set, Set them if we do... #} {% set priceDKK = entry.price[0].DKK ? entry.price[0].DKK : false %} {% set priceEUR = entry.price[0].EUR ? entry.price[0].EUR : false %} {% set priceUSD = entry.price[0].USD ? entry....


1

As mentioned in the Discord you are probably looking for the source function. The reason the include doesn't work is covered in the old PR for (what eventually became) source. It's probably best I link all that discussion than try to put it in my own words here! Initial discussion with your problem First PR Further PR after discussion (the source function ...


1

Maybe a good excuse to use the spaceship operator (<=>)... Combined with the group filter, this seems to work for me: {% set groupedEntries = craft.entries.section('itbuzz').all()|group('author') %} {% for author, entries in groupedEntries|sort((a, b) => a|length <=> b|length)|reverse|slice(0,8) %} <h3>{{ author }}</h3> {#...


1

So, the solution, as provided by @Maverick in their comment above, is just to pass the variable as a query param (?cat=foo), and check for that query param's value in the template.


1

Not Commerce 2, but in Commerce 3, like this: {% set userIdsWithSubscriptions = craft.subscriptions.limit(null).all()|group('userId')|keys %} {% set users = craft.users.id(userIdsWithSubscriptions).all() %} <ul> {% for user in users %} <li>{{ user.username }}</li> {% endfor %} </ul> Via Nathaniel @ Craft Support (thanks!)


1

Related: here's article on my blog about generating placeholder images uing Twig macro: Placeholder image macro for Craft CMS


1

For now, you have to use a plugin I recommend one of these 2 Craft Cookies Plugin https://github.com/nystudio107/craft-cookies Craft LJ Cookies Plugin https://github.com/khamer/craft-lj-cookies


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