New answers tagged

1

It looks like you're missing a closing {% endcache %} tag towards the end of your template. (See https://docs.craftcms.com/v3/dev/tags/cache.html) You might also be missing a closing {% endminify %} tag too, but I'm not sure if you've posted the whole of your template or not.


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

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

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


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

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!)


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 #} {% ...


Top 50 recent answers are included