Questions tagged [array]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
12
votes
4answers
8k views

What is the best way to exclude an array of entries?

I have done a "Is featured" switch on articles which works great. I can list the latest 4 featured articles but after that I would like to list the others (Of course they may be featured too)...
5
votes
2answers
20k views

Using Twig to merge an array and remove duplicates

Problem I'm building a .json file for a search component of a used cars website. The file needs to be built from the output of two sections within CraftCMS, Used Cars and Vans & Trucks. It ...
8
votes
1answer
37k views

Creating dynamic array and set keys

I have content which needs to go into a certain column so I have a field called 'column' there. I can create the array I want by hand: {% set items = { 1 : { 0 : 'Quick Facts',...
2
votes
1answer
717 views

Eager-load and pagination

I'm currently working on a relation-heavy website with a colleague of mine and, for that reason, eager-loading stuff looks very appealing to us. We've succeeded in eager-loading pretty much everything ...
2
votes
1answer
2k views

Create an object of objects with merge

I'm trying to create an object of objects, can anyone suggest why object would only contain the last iteration of "itemObject"? {% set object = {} %} {% for entry in craft.entries.section("...
2
votes
0answers
410 views

Checking if a value matches an entry type handle

I am trying to check if a value provided by the user (url segment) matches an entry type, and if not redirect to 404. {% set section = craft.sections.getSectionByHandle('shop') %} {% set entryTypes = ...
2
votes
1answer
173 views

Order a list of categories by number of entries, key not being set

I have modified the code from this question but I'm running into an issue. {% set allCats = craft.categories.group('blogCategories').level(1).find() %} {% set catArray = {} %} {% for cat in ...
1
vote
0answers
428 views

Advanced filtered search: Matrix fields and arrays

Having scoured the forums for similar questions of which there are a few, I'm still struggling to figure out my specific usecase. I have 4 filters and a search box (which searches a custom tag field) ...