Questions tagged [matrix]

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

Filter by
Sorted by
Tagged with
17
votes
5answers
5k views

Solution for Matrix-within-Matrix (or More Robust Table Fields)

I was wondering if anyone has stumbled on a good solution for including matrix-like fields within a matrix block. I’m working on a site where each page's is constructed in one big matrix with several ...
11
votes
1answer
2k views

Matrix field input error from within the control panel

I have a matrix field with around 26 block types with between 2-6 fields on each. It seems like I've hit a limit and cannot add any more fields to any of the block types. I can add a field if i delete ...
16
votes
1answer
2k views

How to get matrix editor into frontend?

I've currently setup a matrix-field for adresses. I added the field as required field to my user-group "Customer". Which breaks the registration, as a user can only be registered, when the matrix has ...
8
votes
2answers
2k views

How to save Matrix data programmatically in Craft 3

How can you programmatically save an entry that has a Matrix field in Craft 3? (Something like this gist for Craft 2)
13
votes
5answers
6k views

Image transforms returning cpresources url

I'm trying to get Craft to render an image transform defined in the control panel. No image is added to the "filelocation/_transformhandle" folder and returns the url "/cpresources/transforms/98" ...
29
votes
4answers
17k views

Test for empty field?

How do I check if a field is blank? I thought it was something like {% if article.articleImage is defined %} Which in this case is testing an Assets field (and seems to work). Tried the same for a ...
5
votes
2answers
2k views

How to save a matrix content of a new entry in my plugin?

I have a section of type channel with a matrix field. I want to know how I would save the matrix content while I save the entry as well. I know I can save the entry as follows: $entry = new ...
10
votes
2answers
2k views

Matrix fields within matrix field

Is there a way to place matrix fields inside of matrix fields or also to setup a matrix field with existing fields? We are currently trying not to have duplicate content in terms of fields, but that ...
4
votes
2answers
856 views

Identify immediate siblings block type in matrix

I have a type of content that i use on the homepage of a site I am building, the code is shown here: <ul> {% for point in entry.keyPoints %} <li> <div class="a-...
11
votes
2answers
1k views

Search matrix for blocks with upcoming dates

I have a matrix field with one "event" block type that contains several fields. One of those fields is a date field. Is there a way to get just blocks with upcoming dates?
3
votes
1answer
618 views

Query for blocks across Block Types using the new field parameter?

This is a great new feature of Craft 2.3: It is now possible to set custom field parameters on Matrix block queries. I was wondering what would happen, if two or more Matrix Block Types had a ...
6
votes
3answers
2k views

Getting all content, including Matrix fields from an EntryModel

Initially I was doing $entry->getContent()->getAttributes(), but noticed my Matrix fields were all null. What is the right way to do this? I see that $entry->myMatrixField gives me the ...
8
votes
1answer
1k views

How to update Matrix field on frontend for user profile

I have used the following code to allow our users to update their own profile. Everything works fine apart from not being able to update existing Matrix entries. New Matrix field entries work fine. ...
5
votes
2answers
1k views

How to retrieve entries from two entry-types ordered by different date-fields?

I have two entry-types, 'Events' and 'Reports'. 'Events' have a matrix-field ('eventMultiDate') that allows authors to assign multiple dates to an event (recurring). 'Reports' have the default '...
2
votes
1answer
1k views

Show a table field's column headers in template?

The question says it all. I have: A Matrix field, with A subfield with the type table Two columns within that table of which I want to show the column headers in my template Is that possible and if ...
8
votes
1answer
2k views

How to iterate over matrix field from a plugin

I'm writing a plugin where I have the id of an entry, that entry has a matrix field, and I want to iterate over the blocks of the matrix field. In php. How do I do that? Pointers to good documentation ...
3
votes
1answer
951 views

Managing Frontend JS for Matrix Fields

What is the best course of action to allow the creation/deletion of matrix fields in front-end. For context this in a Commerce Order Field. JS is mess right now, any underlying Craft JS libraries I ...
1
vote
1answer
396 views

Find entries that have a category selected from a category field within a matrix block

I've got a Section that uses a Matrix field, that has a block, that has a categories field in it. I want to find all entries using this Matrix field, who has a categories field and has a certain ...
1
vote
1answer
1k views

How do I get the column headers of a table in a matrix?

I'm trying to write a general purpose matrix template and I've come up on a little snag with tables fields. I see no way to get the column header values. The answer here mentions craft.fields....
6
votes
1answer
550 views

How can I return specific matrix rows based on criteria?

So let's say I have the following code. I have the data to retrieve the entry I want, But I only want to return some of the matrix rows based on some criteria. Example Code: {% set entryId = 1 %} {% ...
3
votes
1answer
1k views

Duplicating Matrix fields with content from another locale

I'm working on an Element Action that will duplicate some fields from the primary locale, to whatever locale the user is currently in, if those fields are already empty. Asset fields seem to work ...
2
votes
1answer
300 views

How to get all images from entries including Matrix field

I have a photo gallery that pulls in all entries and then finds the images within them and then displays them along with links to the entries that used that image. Except, it's not pulling in the ones ...
2
votes
1answer
133 views

Missing Matrix row types on output after upgrade to Craft 3 (subsetting and cloning ElementQueries)

Update: Now I know the cause of my problem, I have appended to the original question title to try and help other people stumbling across the same issue. I have a pending support ticket open with P&...
0
votes
1answer
433 views

Categories Related To Matrix Fields

Please help me build my sandwich locator maker :) I have 3 categories, breads, meats, condiments I have a Section called subShops with a matrix field. My matrix field is called sandwichBuilder, ...
11
votes
2answers
2k views

Can I get an entry by Matrix Block ID?

For a url like domain.com/example/123 where 123 is a Matrix Block ID (not an Entry ID), can I get the associated entry for given block ID in a template? Or, for a more general approach, what would be ...
3
votes
2answers
671 views

How do I select entries that have a particular block type?

Say I have a channel with a matrix field which has two block types - text and video. Is there any way to select all entries in that channel that have a video block? Idea 1 Use the Low Blocks plugin ...
6
votes
1answer
504 views

How can I display related entries selected within a Matrix field?

Consider an employee listing... I have 2 sections: 1 for companies, 1 for personnel. In the personnel section, there is a matrix field within which one field is a relational one to relate the staff ...
5
votes
3answers
1k views

How do I get Matrix elements to copy their content across language Locales?

I returned to a site designed months ago, and added a second language to it. From the beginning, this site had prominent composition of entries out of multiple elements in their matrix, with ...
4
votes
2answers
738 views

How to query with relatedTo of a Relationship Field in a Matrix Field block

I have structures called Instrument and Person. On the person structure, I have a Matrix field called Roles. Roles has a block called Musician. And That block type has a Relationship Field called ...
4
votes
3answers
2k views

Output matrix field data

I have a matrix field with a block called "employment", under this block are fields, one of those fields is a drop down. I'd like to be able to output the drop down field as a select list so users ...
3
votes
1answer
337 views

How can I repopulate a matrix field on a front-end form?

I have a matrix field on my front-end form. Everything is working properly, data is saved correctly etc. I am testing & trying to break things and I noticed I wasn't repopulating those fields if ...
3
votes
1answer
1k views

Get related entries from matrix field

I have a matrix field with one block type. In that block type, I have one field that is a related entries field. How do I access the title from the related entries field from the matrix field? Here ...
1
vote
1answer
2k views

Modelling flexible content sections and recommendations

A little background first; I'm coming from WordPress, along with the Advanced custom fields (ACF) plugin, so my thinking behind this may not be the best way in Craft. In ACF I usually set up a field ...
1
vote
1answer
577 views

Is it possible to have category listing page of entries if the category is defined within a matrix block inside said entries?

I think I have been staring at this problems too long and I need a kick in the right direction... Here is what I have (the content modeling is a tad wonky but this is what we're dealing with): ...
5
votes
1answer
2k views

Return Matrix Field block number

Just wondering if there's a way to return the matrix block number during the loop? For example: {% for block in entry.myMatrixField %} {% if block.type == "quote" %} <blockquote class="...
5
votes
1answer
929 views

Save matrix block to new entry in plugin

I have been trying two separate methods to accomplish and both keep resulting in the same errors no matter what I try. The entry I am saving has a few fields the last of which is a matrix block (I am ...
4
votes
2answers
855 views

Inserting Relationship Into Entries Field - Plugin Not Saving Relation

I was hoping someone could shed some light on this issue I'm having. I'm trying to update a relationship field through a plugin, without much success, the entry looks like this: I saw a post on here ...
2
votes
1answer
236 views

How do I group matrix blocks into batches of 4?

I am building a site which uses one content type as its primary holder for content. This is to make content editing easier on the content editor. All URL's are primarily accessing this one content ...
2
votes
1answer
836 views

Dynamically iterate over a matrix block's fields?

Is there a way to dynamically iterate over a matrix block's fields such that the template doesn't need to know the field handles? This doesn't work: {% for block in entry.myMatrixField %} {% for ...
2
votes
1answer
437 views

How do I cycle a class on a Matrix block?

I am trying to add a class which will cycle through on every iteration of a matrix block type, here is my code: {% for block in entry.asideNavigation %} {% switch block.type %} {% case '...
2
votes
2answers
267 views

Element Query matrixfields where

I'm trying to query entries in a section where the (activities) entry has an item in a matrix field timeSlots -> timeSlot -> startDate. The startDate must be >= NOW(). $query = Entry::find()->...
1
vote
1answer
750 views

Search for matrix field in a global set

I've set up a global set "attachmentGlobals" with a matrix field inside named "globalFiles". This matrix has only one block "files" which has a text field "fileId" and an Asset field "fileAsset". I ...
1
vote
1answer
523 views

Search entries by matrix field

I have a matrix inside of which I have 2 fields, 1. dropdown list containing download types and another asset field. I would like to search first by a category and then I would like to further filter ...
1
vote
2answers
675 views

Solution to default template with all possible fields and determine position

Banging my head on this one and have not been able to come up with a solution to this. I'm wanting to create a default template for all single entries that checks for all of the fields I have created ...
1
vote
2answers
1k views

Matrix loop nesting issue using switch

Anyone know if it's possible to check what the current field is while in a loop of a matrix block? Running into an issue with a matrix block in my loop for how I want to output the content. {% case '...
4
votes
1answer
858 views

Group by Field in Matrix Field

Is it possible to group by a field within a matrix field. I have a channel of players which holds their details. I have a structure for teams which includes a matrix field for a Player. The Player ...
4
votes
1answer
384 views

How can I iterate more than 100 blocks in a matrix field for loop?

I am looping through a matrix field and it appears to stop looping when the index reaches 100 but I have more than 100 blocks here. How can I loop through the remaining blocks? {% for block in entry....
3
votes
1answer
548 views

Filtering Matrix through field value and multiple relations

I've the following situation: Accommodations (entry) title description (textfield) ... linkedTo (matrix block) Sport (category) targetGroup (category) minimumAge (number) maximumAge (number) What ...
3
votes
1answer
266 views

Setup default Matrix blocks and default values for sub-fields?

Question is what table can't achieve, can be achieve by matrix but problem is matrix cannot have default row value like table have. Anyway to achieve it? Thanks.
3
votes
1answer
1k views

How do I retain form input values after submitting error-ridden form containing matrix field inputs

I'm looking for a way to keep matrix inputs populated with their original value after submitting a form containing errors. I'm already aware of the method of doing this for general inputs as shown ...