Questions tagged [merge]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
32 views

Update array inside array

So I've read all the posts and followed along at home. I'm not a CS major. I have an array: {% set testArray = { name: "John Doe", email: "[email protected]", players: [ { ...
stuartmcd69's user avatar
1 vote
1 answer
30 views

Prevent merge from removing data

I have a loop like this: {% set markers = [] %} {% for product in products %} {% for category in product.categories %} {% if category.level == 1 %} {% set data = ...
Tyssen's user avatar
  • 609
1 vote
1 answer
100 views

How best to merge an array into an array for a relatedTo query parameter?

I have 3 Matrix fields which define optional parameters for building a query: A related Entries field A Categories field A Tags field Any combination of them could be used, including none or all. So ...
Jonathan Schofield's user avatar
0 votes
2 answers
66 views

How to dispatch equally entries from different channels?

I have entries from two different channels, where each channel has a different total of entries, and I want to display them equally by batch. Example: Channel #1 | Channel #2 | Channel #1 Channel #1 | ...
Romain Poirier's user avatar
1 vote
2 answers
547 views

Merging classes in Twig based on component and context

Whats the best way to approach this in twig? So I have a component that is used in multiple places, so within this component I set some default classes like so: {% set navSidebarClasses = { heading: ...
Terry Upton's user avatar
  • 1,884
0 votes
0 answers
82 views

Split categories by levels / List categories merged by name

I have a scenario where I need category levels (4 levels) split in different sections of the page, also some categories have the same name, I explain: I need to list entries based on a category group ...
user15280052's user avatar
4 votes
1 answer
88 views

Modified A-Z grouping

I'm trying to output the alphabet where certain letters are enabled/clickable based on whether any entries from a specific section start with that letter. Here's the UI: Getting the A-Z is easy ...
A Herrera's user avatar
  • 309
1 vote
1 answer
25 views

Merge list of categories related to 'project' entries - not working, a solution

good to be back) Helping a friend out with a website for his tiling business. The site contains a 'projects' section which displays category-filter buttons allowing the user to toggle relevant ...
Matt P's user avatar
  • 1,538
0 votes
0 answers
93 views

Search Results not working as expected

I have a search results page set up where there are a number of parameters in the query string used to filter results. I've got 3 out of 5 of these working and am stuck on the final 2. My full ...
CreateSean's user avatar
  • 1,963
2 votes
2 answers
190 views

Merge, shuffle, and paginate 😱

I'm trying to get a list of users from two different user groups. One user group (premium) must always show first. Whenever the page is loaded, however, the listing of users should show randomly (...
A Herrera's user avatar
  • 309
1 vote
2 answers
172 views

Show only and merge the entries from multiple categories related to that entry

I want to show the entries which have same category of that entry. The entry might have multiple categories, so I want to merge the result. If there is a result, then only the whole structure will be ...
Lee's user avatar
  • 139
3 votes
1 answer
636 views

How to duplicate entries and loop them without getting a Twig or deprecation error?

I'm trying to duplicate entries inside a macro, which will displays duplicated items inside a carousel. It's not possible to merge Element Queries. Even if it's possible to merge IDs, merging an ...
Romain Poirier's user avatar
1 vote
1 answer
22 views

Problem with data hash only storing last entry in loop

1: I'm creating a data hash object and then looping through a collection of entries to store the results of various macros in it: {% set data = {} %} {% set people = craft.entries().section('people')...
Jonathan Schofield's user avatar
1 vote
1 answer
223 views

Pagination and "if" condition

Some of my entries have the same entry.title. At the frontend, I would like to display these entries only once. This works with the following code: {% set entries = craft.entries().section('produkte')...
TomS's user avatar
  • 213
1 vote
1 answer
47 views

Merge trashed element with existing one

Is there any way to merge trashed elements with an existing element? I'm creating a custom restore action so you can merge a trashed (commerce) Product with an existing one. The mergeElementsByIds ...
tim-pixeldeluxe's user avatar
1 vote
1 answer
32 views

Merging params PostDate limits errors

I'm attempting to merge in postDate restrictions based on the url segment. However I get twig errors with my code. So for a link of domain.com/news/archive/2016 I want to see all entries with a ...
CreateSean's user avatar
  • 1,963
3 votes
2 answers
728 views

Paginating Merged Element Queries

I really want something like this to work but the merge function turns Elements into Arrays. I've managed to work around it other times but what's the best practice to combine two entry sets and then ...
Matthew Rotter's user avatar
1 vote
2 answers
112 views

Merging Assets Fields

I've got this working but it seems terribly verbose to do something, that in my opinion should be easier. Is there a better way to get the assets from 2 different fields, merge them and output them ...
CreateSean's user avatar
  • 1,963
1 vote
1 answer
98 views

How to merge SEOmatic object in Craft 3?

I'm using SEOmatic plugin in craft cms 3 and I need to set the seoTitle in my template but can't figure out how to do it... I know that in Craft 2, it was possible to merge the seomatic variable. I ...
Elodie Grondin's user avatar
0 votes
1 answer
66 views

Replace quotes in an array

I'm trying to use a charting library within a Craft template. The chart expects an array of numbers that I'm building up from a table but I'm getting an array of strings instead. {% set donutData = [...
Steven Grant's user avatar
  • 1,855
1 vote
0 answers
123 views

Merging Entries - Craft 2 worked but not Craft 3

I have this code which merged entries when in Craft 2 {% set entriesOne = craft.entries.section('publications').search('nonMembers:0').ids() %} {% set entriesTwo = craft.entries.section('...
CreateSean's user avatar
  • 1,963
1 vote
1 answer
195 views

filter matrix blocks by multiple light switch value, and then merge them

I have a (Craft 3) matrix field with two different block types that each have a similar light switch field that I want to use to create anchor links on my page. I need to be able to test whether any ...
artmem's user avatar
  • 1,012
3 votes
1 answer
2k views

Merging 2 Entries Array's

I have these to arrays that I need to merge into one array, but can't figure it out. Please advise {% set entries = craft.entries.section('publications').search('nonMembers:0') %} {% set entries = ...
CreateSean's user avatar
  • 1,963
2 votes
1 answer
147 views

What is the correct syntax for using merge to create an array of field values from an element query?

I grab some values via an element query: {% set events = craft.entries.section('events').status('live,pending').order('postDate asc') %} But I need to put them into an array for use in a Craft-...
4midori's user avatar
  • 606
1 vote
1 answer
269 views

Merging Multiple Relations as params

I have the following code where I'm pulling entries related to another entry which works fine. However I also want to limit the entries returned on a category page and thus am merging in a relatedTo: ...
CreateSean's user avatar
  • 1,963
1 vote
1 answer
2k views

Search Multiple Fields Same Parameter

I'm building a search form with filters. This is one of the filters. I would like to use the parameter "agent" and have it search a text field called "listingAgent" and "coListingAgent" to check for a ...
triplethreat23's user avatar
1 vote
2 answers
800 views

Using Merge filter

I am trying to use some Twig code to sort entries by a date field that is contained within a Venti field. Here is the code: {% set allWorkshops = [] %} {% for entry in craft.entries.section('workshop'...
Roi Agneta's user avatar
  • 1,403
2 votes
1 answer
6k views

Merge a multidimensional array

I am creating a calendar for displaying films and their screening times. I already have a quite convoluted mechanism of retrieving data from the "films" channel, where I have a supertable for "...
LosHosez's user avatar
  • 111
5 votes
4 answers
19k views

Overwrite value in object in array

I'm strangely having trouble with this simple Twig merge problem and can't find anything online. Simplified, let's say you had: {% set users = [ {name: 'Bill', age: 25}, {name: 'Tim', age: 30}...
Ryan's user avatar
  • 1,942
0 votes
1 answer
123 views

Merge related entries from several matrix blocks while maintaining other matrix field data

I have a matrix that essentially creates categorized lists of other entries. The fields in my matrix block are "categoryName", a plain text field and "member", a entry relationship field. I know i ...
artmem's user avatar
  • 1,012
1 vote
2 answers
1k views

Merge two queries of entries ordered by publication date

I got a section called news which contain 2 types of entries: news and press. Those entries are linked with 2 different categories : news entries have category newsType and press entries have ...
Miguel Bocquier's user avatar
3 votes
1 answer
2k views

Possible to merge and sum the values of an array?

I have a super table that has 4 columns. I'm trying to create an array based off one column (contentType) and merges to get only the unique values while taking the sum of a different column (points). ...
Siebird's user avatar
  • 373
2 votes
1 answer
149 views

Query two sections filtered by different custom fields, then order them

Two channels: 1) exhibitions, which have a startDate and EndDate 2) events, which have a date I need to grab the current exhibitions, future exhibitions and future events, which I do using this: {% ...
Clive Portman's user avatar
1 vote
1 answer
259 views

If merging two sections from different locales how do I then sort them by a shared criteria?

I've got a site with multiple locales and I want to merge together content from across these locales, eg News. The two sections share the same fields so should theoretically be able to be sorted by a ...
Cole Henley's user avatar
  • 1,741
2 votes
1 answer
3k 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("...
joep's user avatar
  • 610
1 vote
1 answer
127 views

Merge Entries but only after X amount of entries

I'm trying to get entries from two sections and merge them together which is pretty straight forward using the merge filter. For example, my sections are: News Promoted News But, my main issue is I ...
Jason Mayo's user avatar
3 votes
1 answer
189 views

How to merge/combine/transfer-entries-between two categories in the CP?

I’ve got 2 categories each with lots of entries. The client wants to delete one category, and transfer it’s entries into the other one. If I delete the category, it just disappears, but I somehow ...
Simon Clayson's user avatar
0 votes
2 answers
328 views

Merging Hash Error

I'm having issues trying to merge a nested hash to get unique values. I'm getting this error which points to the last line of for the loop: A hash key must be followed by a colon (:). Unexpected ...
Siebird's user avatar
  • 373
0 votes
1 answer
284 views

Order merged query by shared field

I’m trying to merge two query sources (some entries and some categories) but have them ordered by a shared field that is a date field. Here’s what I have so far: set classesLocations = craft.entries....
Mike Pierce's user avatar
1 vote
1 answer
628 views

Correct way to merge craft.user field arrays and use outside the loop?

I'm using preparse field plugin to limit the amount of tags a user can add to his account. I've modified the code slightly so the tags are processed as a comma, separated, list. The plan is to ...
Rob's user avatar
  • 865
5 votes
2 answers
23k 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 ...
R0wan's user avatar
  • 335
2 votes
2 answers
6k views

Adding entries to an array, one at a time

I'm trying to loop through some entries and if they fulfil a certain condition push them into another array of entries. {% set todaysEvents = [] {# GET TODAY'S ONE-OFF EVENTS #} {% set ...
Clive Portman's user avatar
2 votes
1 answer
720 views

Shouldn't this merge be working?

Can anyone help me work out why the following returns the error "The merge filter only works with arrays or hashes."? {# CREATE ARRAY TO HOLD ALL OF TODAY'S EVENTS #} {% set todaysEvents = [] %} {# ...
Clive Portman's user avatar