Questions tagged [merge]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
2answers
76 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: ...
0
votes
0answers
45 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 ...
4
votes
1answer
76 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 ...
1
vote
1answer
15 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 ...
5
votes
4answers
15k 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}...
0
votes
0answers
53 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 ...
2
votes
2answers
112 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 (...
1
vote
2answers
81 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 ...
3
votes
1answer
215 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 ...
1
vote
1answer
20 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')...
1
vote
1answer
145 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')...
1
vote
1answer
33 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 ...
1
vote
1answer
22 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 ...
2
votes
2answers
382 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 ...
1
vote
2answers
72 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 ...
1
vote
1answer
90 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 ...
0
votes
1answer
37 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 = [...
1
vote
0answers
106 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('...
1
vote
1answer
161 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 ...
3
votes
1answer
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 = ...
2
votes
1answer
98 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-...
1
vote
1answer
230 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: ...
1
vote
1answer
1k 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 ...
1
vote
2answers
500 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'...
2
votes
1answer
5k 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 "...
0
votes
1answer
98 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 ...
1
vote
1answer
841 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 ...
3
votes
1answer
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). ...
2
votes
1answer
143 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: {% ...
1
vote
1answer
217 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 ...
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("...
3
votes
1answer
132 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 ...
1
vote
1answer
116 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 ...
0
votes
1answer
265 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....
0
votes
2answers
307 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 ...
1
vote
1answer
566 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 ...
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 ...
2
votes
2answers
5k 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 ...
2
votes
1answer
706 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 = [] %} {# ...