Hot answers tagged

3

Instead of duplicating the entries, you could run your entries loop twice (or as many times as you want) maybe? {% for i in 0..1 %} {% for entry in entries %} {{ entry.title }} <br> {% endfor %} {% endfor %}


2

Do you mean to have it just assign them one after the other? If so, then you can just use Twig’s cycle function. {% set themes = [ 'yellow', 'red', 'teal', 'blue' ] %} {% for region in regions %} <a href="{{ region.url }}" class="text-{{ cycle(themes, loop.index) }}">{{ region.title }}</a> {% endfor %}


2

How about this; you get the pull quote index by dividing the loop index by 4 (will always return an int) and then you modulo that index against the length of your quotes array: {% if loop.index % 4 == 0 and not loop.last %} {% set entry = pullQuotes[(loop.index / 4) % (pullQuotes | length) - 1] %} <li class="w-full flex justify-center mb-12"&...


2

The easiest solution for this would be either a special fieldvalue or a property in a behavior that you set in your job. class MyJob extends BaseJob { public function execute($queue): bool { // do some api calls here // .... $entry->isSavedViaApi = true; $entry->setFieldValue('browsershotUrl', [$assetId]); ...


1

You don't mention what your related entries field handle is, but remember that calling any related element (entries/assets/categories/users/tags) will require a .all() (or .one() or .ids() or one of the other query-executing methods) unless the related elements are eager-loaded. With that in mind I can't see anywhere in your code where you're executing a ...


1

You should use .all(), but that will give you an array of Assets. You can't call .getUrl() on an array, so you'd have to loop that array: {% for entry in craft.entries.section('projekte').all() %} <a href="{{ entry.url }}"> {% set images = entry.startbilder.all() %} {% if images |length %} {% for image in ...


1

Updating for Craft3 and calling for different types, I wanted to share how I use the entry types to create different header/slider entry. {% set slides = craft.entries().section('slider') %} {% set entries = slides.all() %} {% for entry in entries %} {% if entry.type == 'type1' %} {# Your content for 'type1' Entry here #} {% endif %} {% ...


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