Hot answers tagged

3

"Measure twice, cut once" goes the saying... (Kind of the opposite here, but the same principle!) - Fetch your data once, then cut it up how you like using Twig filters. In your case you can fetch the first item from an array with [0] and then slice off that same entry from the start of the same array with |slice(1) like this: {% paginate craft....


2

You can use Twig's loop variable (docs). {% for asset in relatedEntries %} <div id="locate" class="locate"> <div class="portname"> <a href="/memory/index.php/bio/{entry_id}">{{ loop.index }} {{ asset.title }}</a> </div> </div> {% endfor %}


2

I would use a macro to output the contents of a single nugget (matrix block), this way you don't have to repeat the include statement multiple times. The only thing you need to keep track of is the current index, i.e. which item is next. You can't do this inside the macro, since a macro can't have persistent state. You have two options: Set up a variable to ...


1

Based on the example you linked: You can prevent duplicate entries by explicitly excluding the entries you've already seen using the id method. Since you already have an array of IDs you have already displayed (existingIds), you only need to prepend 'not' to negate the query and exclude those entries: https://craftcms.com/docs/3.x/entries.html#id {% set ...


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