Questions tagged [matrix]

Matrix fields allow you to create multiple blocks of content within a single field.

59 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
134 views

Eagerloading Matrix fields resulting in empty array

I'm trying to eager-load a Matrix field with it's blocktype and related field types. For some reason the _eagerLoadedBlockTypeElements are empty arrays. If I get rid of the with clause on ...
2
votes
0answers
154 views

Neo performance (large page)

I'm using Matrix and Neo to build out quite large, complex entries. On larger pages (70+ blocks each with one-multiple sub-blocks) the performance is taking a bit of a hit taking upwards of 40 seconds ...
2
votes
0answers
111 views

Can't seem to get reverse relational field working from within a Neo field

Has anyone managed to get reverse relations from a Neo field working? I have a Neo field containing an Entries field which works fine on the page/section entry where I have the Neo field, but I’m ...
2
votes
0answers
94 views

How can I validate/make a matrix field required on the front-end?

I am displaying inputs on the front-end of my form that are populating a matrix within the CP. Overall everything is working fine. The problem I am having is validation. I've got the field marked as ...
1
vote
0answers
26 views

Migrating to Matrix using Feed Me and Element API

How can I use Element API to move my entry fields into a matrix-based content builder? I'm going off the docs found at https://docs.craftcms.com/feed-me/v4/guides/importing-into-matrix.html#setup-your-...
1
vote
0answers
26 views

Syntax for eager loading assets from multiple matrix block types

When eager loading assets from within a matrix block like so: {% set blocks = entry.relatedCategory .with([categoryBlocks.blockType.blockAssetField]) .all() %...
1
vote
0answers
59 views

Importing set of flat fields into multi-row matrix using Feed Me

I'm using 'Feed Me' in Craft 3 to import data. The data has 9 fields (like full_name_child_1, and gender_child_1...) and has 10 sets of them (all the way to full_name_child_10, etc). I originally ...
1
vote
0answers
100 views

How to exclude a Matrix block from search?

I'm using a Matrix field as a content builder, allowing the editor to freely create content blocks, titles, images, etc, etc. All of which is content that is required to be searched. But also included ...
1
vote
0answers
48 views

Order entries by a matrix field category

I have a lot of trouble in understanding the database/model structure and how to work with the query builder. I tried playing a bit with leftJoins but i cannot seem to make complex queries in craft 3. ...
1
vote
0answers
91 views

Craft 3: Possible to merge checkbox and text values from a frontend form and put into a plaintext Craft field?

Is it possible to submit checkbox array and text values on a front end form into a plaintext Craft field in Craft 3? My solution worked in Craft 2 but it broke in Craft 3 due to some under the hood ...
1
vote
0answers
28 views

Why does calling matrix block type before matrix block loop lead to no loop output

In the code below I am trying to check for the presence of a quote block to help define some layout columns. As soon as i count an individual block, the loop block below it outputs nothing. If remove ...
1
vote
0answers
63 views

Idea for matrix alternative for multisite setup. Feedback needed!

We have a site that has relied heavily on the use of matrix fields to act as a content builder for several pages on our site. We are now in the process of localizing the content, and have set up ...
1
vote
0answers
46 views

SuperSort Matrix Block sort by Year / Month / Now Data

{% set allCVs = entry.profileCv.all() %} {% set cvEntries = [] %} {% for item in allCVs %} {% set fromMonth = item.fromMonth.value %} {% set fromYear = item.fromYear %} ...
1
vote
0answers
238 views

Join Matrix Fields To Query Using andWhere

My question is this, I want to join a matrix table to a query and look for certain values in it. I am using this example below. I have 2 matrix fields partsModels.model and partsModels.parts. I need ...
1
vote
0answers
97 views

Front end entry dropdown with null option

I have successfully implemented a front-end form that allows the user to add new "blocks" to a certain matrix field. This matrix field has one text field, two date fields, and one entry field that ...
1
vote
0answers
71 views

Import CSV to matrix field

How should I structure a .csv and process the data to import matrix fields? Whith table I used a json_encode but of course this doesn't work with matrixes.
1
vote
0answers
321 views

Using element API to query a matrix field

I'm using the Element API to grab entries and their data (via this answer). What I want to do is accept a URL parameter (eg. ?location=foo) and filter the returned entries by a Matrix field called ...
1
vote
0answers
43 views

Attaching a file to a Matrix field and then saving the entry takes up to 2 minutes

I have an issue with attaching a file to a Matrix field and then saving the entry takes up to 2 minutes. If I open up another tab with the Craft CMS admin interface I can see that Craft is performing ...
1
vote
0answers
175 views

Frontend upload asset to Matrix

I created a matrix with 1 type, 3 fields for user profile. I use front-end to upload file to documentUpload field. But I got PHP warning: array_merge(): Argument #1 is not an array message. I Google ...
1
vote
0answers
66 views

Display entries linked from Matrix field according to the entries' structure and a light switch in the Matrix

In a channel (market), I have a Matrix field (market_products) with a Stucture-based Entries field (products) and a Lightswitch field (active/inactive). For each market, I need to create an ordered ...
1
vote
0answers
130 views

Combined searches and filters with a Matrix

I am fairly new to Craft but have managed to build a combined search feature that users can filter from dropdowns. I used this as a guide and it works great: https://webstoemp.com/blog/combined-...
1
vote
0answers
284 views

Getting type of element inside of a matrix field using plugin hook

I've been trying to deal with saving matrix fields to an external API by hooking onto the craft()->on('entries.saveEntry) function in a custom plugin I made. Matrices are nice for content authoring,...
1
vote
0answers
64 views

Search syntax for searching matrix fields (in the CP)

Looking for a way to search (in the CP), for elements where a matrixField is empty or not. This seems to work: - with matrix rows: myMatrixField::* - without matrix rows: -myMatrixField::* However, ...
1
vote
0answers
51 views

Return Category from Inside Matrix

I'm having difficulty returning a category from inside a matrix block. So I'm returning a student based on a studentNumber variable {% set studentParams = { section : 'students', '...
1
vote
0answers
155 views

Saving some entries and a matrix field settings takes a very long time

I have some issues with saving fields and entries in Craft. For some reason, some entries, and a Matrix field I have, take approx. 1 to 2 minutes to save. There are then errors in my server log. ...
1
vote
0answers
416 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) ...
1
vote
0answers
100 views

Grouping entries by days in matrix field

So this is proving a lot harder than I thought. I have a 'tours' section containing tours, which all have several departure dates. Those dates are in a matrix field, entry.data. So there's only one ...
1
vote
0answers
49 views

Possible to repopulate locale defaults?

When a locale is first created, it seems it receives all of the default locales content. Is it possible to have this happen for a specific field after the fact? I have a large matrix (with subtle ...
1
vote
0answers
180 views

Delete matrix blocks based on their content

Is it possible to pragmatically delete a matrix block based on its content? I have a channel called "Artist", which has a matrix field with concerts. It'll be about 5-600 concerts in total every year, ...
1
vote
0answers
311 views

Best way to save user data?

I have a user model that contains several Matrix fields, but for the sake of this question I'll just discuss one of those fields. The field we'll discuss is a phoneMatrix. The phoneMatrix data can ...
0
votes
0answers
14 views

Super Table fields in Matrix blocks not automatically propagating content across sites

Please bear with me as I try to explain what's going on. Feel free to ask for more details if needed. Simply put, Super Table fields in Matrix blocks are giving me trouble for multi-site. I am ...
0
votes
0answers
15 views

How to add new Matrix block to entry field in php?

$draft = new Drafts(); var_dump($entry->slug); $draftEntry = Entry::find()->slug($entry->slug)->one(); $draftEntry->typeId = 32; ...
0
votes
0answers
29 views

Entries search parameter for date value in matrix field no longer working in Craft 3

We have a large festival events site where each performance is stored in a matrix field called dates which uses a single block which has a datetime field (date only). So if an event is on 3 different ...
0
votes
0answers
13 views

How can you add a default set of fields to each matrix block?

We have a common set of default parameter fields I'd like on each matrix block on top of whichever other fields are configured. I'm trying to avoid managing them manually on each matrix block. What's ...
0
votes
0answers
22 views

Best way to display relevant matrixblock fields when doing a sitewide search?

I'm building a custom search results page which returns not only the entries that contain the search query (searchQuery), but also, the actual text/content in which the search query was found. That ...
0
votes
0answers
26 views

Any second field in Matrix block coming out as NULL

For some reason, any time I add a Matrix block and add a second field it doesn't show - value is NULL. I upgraded from craft 3.2 to 3.4 recently.
0
votes
0answers
19 views

Query Events by Matrix Field using Where clause

I am new to Craft CMS. I am able to get a list off all upcoming events with: $events = Calendar::getInstance()->events ->getEventQuery( [ 'calendar' => 'sample_calendar', ...
0
votes
0answers
42 views

Entry matrix field returns empty array

I have updated Craft from 3.3.15 to 3.4.2 version, and encountered the following problem. I have a form that creates entry which has matrix fields in it, entry is successfully saved in the database ...
0
votes
0answers
23 views

Eager loading showing duplicated DB query

So I've had a read on Eager loading on CraftCMS from an article by nystudio107 and begun enhancing my website for a client but I'm currently running into an issue which I'm not sure could be fixed or ...
0
votes
0answers
22 views

Immutable alternative to Matrix block id?

We're currently using this code to generate a class name that can be used to style a matrix block on the fly (ad-hoc): {% for item in matrix.all() %} <div class="page-builder__item-{{entry.id ?? ''...
0
votes
0answers
23 views

Matrix field not displaying after updating to Craft 3

According to the documentation, this should loop through all Matrix fields. {% for block in entry.fieldname.all() %} But it's showing nothing. Everything is showing in the CMS itself, but not on the ...
0
votes
0answers
22 views

Craft 3 Programatically Adding Block Types To Matrix

I have been attempting to programatically add blocks to a matrix field using the below code as part of a larger plugin learning project. use craft\fields\Matrix; use craft\fields\PlainText; //Create ...
0
votes
0answers
20 views

Missing Matrix content after upgrading from Craft2 to Craft3

I’m upgrading my Craft2 blog to Craft3 at https://brill.blog. I’ve got a loop to display text, images, and block quotes from a Matrix field, that follows this pattern: {% for block in entry....
0
votes
0answers
14 views

How to create other sites entries with same data, when “Save blocks to other sites in the same group” is used

We have fields, including a matrix field, that is set to "Save blocks to other sites in the same group". This means when we edit our English group, only sites in that group are edited, so they all ...
0
votes
0answers
99 views

Feed me - Trouble importing table and matrix with translation

I'm trying to import entries to a chanell using Feed me but having some issues with table and with some multilingual texte in a matrix field. Craft edition & version Craft Pro 3.3.2 Feed Me 4....
0
votes
0answers
8 views

Craft 3 Matrix Field customFields property 'required' and 'sortOrder' fields null

I'm trying to dynamically build a frontend form based on a Matrix field. I'm iterating over the entry.aMatrixField.customFields array which returns me an array of field objects in Twig. The field ...
0
votes
0answers
41 views

Set field value of table field within matrix in a module?

I have a matrix called 'Election' with the structure: Block: role - Text field: roleName - Table field: candidates -- Text field: fullName -- Number field: votes My module can edit the roleName ...
0
votes
0answers
19 views

SQL to delete all entries and a matrix field from the database direct due to Craft issues in the admin

What would be safe SQL commands to delete all entries from the database? And similarly to delete all content from a specific Matrix field? The reason is because Craft seems to have an issue with ...
0
votes
0answers
130 views

Queue “Failed”, with Attempting to save an element in an unsupported site

I have many sites for different countries and languages. They are grouped by language. I have a matrix field setup to "Save sites to other sites in the same site group". We imported all the sites ...
0
votes
0answers
30 views

Add Matrix Blocks to existing Entry with Form without discarding existing Matrix Blocks

When I want to save an new Matrix block with an form to an existing Entry: <form method="post" accept-charset="UTF-8"> {{ csrfInput() }} <input type="hidden" name="action" value="entries/...