Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [matrix]

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

0
votes
0answers
10 views

Possible to move matrix content from one global set to another

Is it possible within the database to manipulate a couple of keys to move matrix content to another global set without having to re-enter it all in Craft 3? I have the matrix field in both global ...
0
votes
1answer
19 views

Element API unable to get all() of matrix field

I'm getting matrix block content from an entry type which works fine for the most part. It's probably clearer to just paste in the code: Current element api code: $relationsData = []; if($entry-&...
1
vote
1answer
21 views

Loop through Matrix Block fields within a Switch Case and retain HTML structure

I'm struggling to get my head around the syntax to output information in a correct HTML structure. At the moment I have this: {% for block in entry.menuBuilder %} {% switch block.type %} {% case '...
1
vote
0answers
24 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
2answers
24 views

Sprout Reports plugin - How to output a Matrix field into a row

I'm not clear on how I would iterate over a Matrix field to be able to include the content in the row. Wish there was an example in the docs: https://sprout.barrelstrengthdesign.com/docs/reports/...
1
vote
1answer
28 views

Page with Matrix field slow to load

I am fairly new to Craft CMS but have a good understanding of it. I have a page that has a Matrix field to display staff photos and their roles. On the initial load of this page, it is slow, it takes ...
1
vote
1answer
21 views

Craft 3 - Matrix Block for currentUser

I have a Matrix field named -> certificado with block -> certificados and fields -> nomeDoCurso, curso, certificado My Matrix block has no entries but is associated with a user. How can I fetch ...
1
vote
1answer
37 views

Matrix Field - variable entry does not exist

I'm trying to loop a Matrix field that has one block containing 3 items. {% for block in entry.galeria.type('itemsGaleria') %} {% if block.titulo|length %} {{ block.titulo.first }} {% ...
1
vote
1answer
15 views

Entries Field Type showing all entries instead of entries selected

I am new to craft and twig and need some help showing only added entries to matrix block. What I have now is showing all entries from the section. I may be going about this all wrong, I don't know. I ...
1
vote
1answer
31 views

Craft 3: fetching a single Matrix row by its dropdown field value

I have 2 Matrix fields in an entry type, both of which use Dropdown fields: Matrix: urls address (block type) context (dropdown field values include 'own') address urn ...
1
vote
1answer
41 views

Templating repeatable blocks in a matrix field

I have a matrix field that has two different block types. The matrix field is on an entry that lists a number of benefits for a given product on a corporate website. The two different blocks are ...
1
vote
1answer
43 views

Passing optional variable values into an include template

Craft noob here. I have an include file which I'm calling a "component" so I can reuse it across the site. The component is set up like this. <h2>{{ heading }}</h2> {{ bodyContent }} {% ...
1
vote
0answers
37 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
2answers
41 views

Removing old Block Handles in Matrix Field?

I'm working with Matrix field. When adding and then removing and then adding again fields with the same handle I get the following error. Handle "videoUrl" has already been taken. Is there a way of ...
2
votes
1answer
46 views

Tabs in a Matrix Field

In this video it looks like Courtney has tabs (Content | Design) in the individual fields in a Matrix. I can't work out how to do this, is it a plugin? It seems a great way of organising the fields ...
1
vote
1answer
46 views

How to duplicate a matrix field programatically in Craft 3.1?

Is there a "Craft" way of handling this in 3.1? Solutions to this question on SE are based on older versions of Craft which no longer work. Custom fields can be duplicated by doing: $newEntry->...
1
vote
3answers
101 views

Matrix fields in an entry form

I'm attempting to get matrix fields to populate in an entry form (using the guest post plugin) and so far just can't seem to crack it. I've tried various examples, but all assume that you're just ...
1
vote
0answers
39 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
1answer
40 views

Query returns nothing on matrixBlock

I'm a bit confused by the way that Craft now handles Matrix blocks. I've read the documentation a few times and I'm still not sure if I have it. Here's what I have: {% set myMatrixBlockQuery = craft....
0
votes
1answer
79 views

Can't link to entries or assets via a Redactor field

When using a Redactor field for a section, I can’t upload assets or link to entries. I just get an empty modal with no ability to select a section or asset folder. Thoughts on what I’m doing wrong? [...
1
vote
1answer
38 views

How to output 'selected' checkbox labels within a matrix

Newbie here. First Craft 3 CMS build and fumbling with logic of Matrix blocks. I've created a relatively simple matrix field, and I can output plain text and dropdown options, but not sure how to do ...
2
votes
1answer
53 views

Empty matrix object after checking for a block type

Not sure if this is a bug or my logic is off. I'm trying to add caching logic to templates to not cache certain pages if they have a block type form present because of the dynamic CSRF tokens. The ...
2
votes
1answer
55 views

Updating matrix field from font-end with $entry->setFieldValue() pulls in Cp bundle on save

I have an entry with a matrix field which I'm updating from front-end. The update works fine, but when the (font-end) page reloads after submitting the form, the CP bundle assets get included (...
1
vote
1answer
83 views

How to copy Matrix from one entry to another in Craft 3

I've got $entryA with a Matrix field. I want to programatically create a new $entryB and copy the Matrix field from $entryA to $entryB. How do I go about this?
1
vote
0answers
24 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
1answer
37 views

Display a Matrix field block entry when the block's entry exists

I have a videoPost block in a Matrix field. Each videoPost has a imageField. I am trying to display the block’s image if imageField is defined. This is returning images for each block that has ...
1
vote
1answer
35 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 ...
0
votes
0answers
42 views

Indirect Relationship defined in Matrix Block

I have 3 channels: Reviews, Products and UseCases. In the section "Reviews" an entry has a list of "Products", based on a matrix field. Every block in this matrix field represents one listed "Product"...
1
vote
1answer
45 views

How to wrap a matrix blocktype occurrence loop inside a ul?

I made a template including a matrix field. I want to wrap all occurrences of a certain block type into a <ul> element. How can I do this? My current code: {% for block in entry.matrixField....
1
vote
1answer
23 views

How to filter relational field types on their related content's status?

I have a Matrix field on Users. In that Matrix field is an Entries field. I need to pull all Entries from that field, regardless of the related Entries status. The following code returns Users but ...
1
vote
1answer
42 views

Check if the first block in a Matrix field matches one of an array of types

I need to check if the first block in a Matrix field matches one of an array of types. Here's a simplified version of my code: {% if entry.newsArticleContent.one().type in ['fullWidthImage', '...
1
vote
1answer
54 views

includeJs not consistently working

Using Craft 2 and I have a Matrix Block which can contain a carousel item, which uses JS/jQuery. Because the content editor can add multiple instances of this Matrix Block I can’t set up these ...
1
vote
0answers
56 views

How to print all possible options of a dropdown field inside of a Matrix field?

I'm asking this outside an entry context. My starting point is {% set field = craft.app.fields.getFieldByHandle('matrixFieldHandle') %} When I print the data of the field, I find nothing ...
1
vote
1answer
33 views

Inserting Multiple Block Types in one div row

I have a matrix with a block type call pageRelatedContent. A user can add multiple block to their entry. I am trying to put all the pageRelatedContent blocks in one div row. For this example, I have ...
1
vote
1answer
236 views

Bootstrap 4 Accordion with Matrix (and SuperTable)

I'm attempting to use a combination of SuperTable and Craft's Matrix to create a reusable Bootstrap 4 Accordion element, but I'm hitting a wall. My code so far: {% for row in entry.contentBuilder....
2
votes
1answer
35 views

Display matrix block which share the same date field value

I think a better way to achieve this would be with Supertable, but for now I'm wondering if there is a way to group the example output W/C: 27 Aug 2018 {{ block.week }} 1.5 {{ block.totalTime }} W/...
1
vote
1answer
46 views

SQL error when trying to use sortOrder on Matrix related block (Craft 2)

I'm getting the following SQL error when trying to simply order related entries in a Matrix block. Anyway around this? CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity ...
1
vote
1answer
33 views

What could the possible causes be for a mismatch between `craft_fields` and `craft_fieldlayoutfields` MySQL tables?

I'm debugging an Internal Server Error on a site developed by, well, not me. :p The site has an absolutely enormous Matrix field called "Modules", and the blocks in said field have so many fields that ...
2
votes
2answers
71 views

Loop index inside a switch content builder

How would one construct this? I have built a little content builder and wish now to change the layout HTML on the fly when there are more than one matrix block. In the example below, this is just one ...
1
vote
2answers
70 views

Find entries that use a specific block in their Matrix field?

Suppose a Mtrix field named MyMatrixField has three blocks called Text, Images, and Buttons. What MySQL query would list the section and title for all entries whose MyMatrixField field has a Buttons ...
1
vote
0answers
41 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
1answer
145 views

Get and Set existing matrix field data in a plugin

I have a plugin that wants to set a value for an entries existing matrix field, from a form on the font-end. Think of it like: Movies (matrix field) Movie (matrix block) Name (plain text) ...
2
votes
1answer
108 views

FeedMe: How to import data into the Matrix field of a section?

I have a section called "Musicians" which is already set up and populated. It has an unpopulated "Albums" Matrix field which will hold each artist's albums. I have exported the albums as a separate ...
4
votes
1answer
44 views

Asset dynamic subfolder for User Matrix

I need to set an asset field's dynamic subfolder path to the User ID. The field is within a matrix. The matrix a field in a User profile. Setting it to {currentUser.id}, {owner.author.id}, {object....
1
vote
1answer
58 views

Your usual setup for blogpost matrix field [closed]

What is your usual setup for blogpost/article matrix field? I can think of: Header Richfield Quote (author+text) Image(asset, position, description)
1
vote
1answer
45 views

Entries from matrix should not appear in loop

I have a Matrix with an entry field. I have a Loop which is looping entries out of a section. Goal: The entries from the matrix should not appear in the loop of the section. So the Matrix defines ...
1
vote
1answer
131 views

Output assets within a matrix block using Imager and Craft 3

I'm having trouble trying to output assets from an Assets field that's within a Matrix block, using Imager. The code below is only outputting the first image that has been added, over and over for ...
1
vote
1answer
253 views

Check if a value exists in a Matrix field

http://sanderson.brycekirk.com/floor-plans/1-bedroom-1-bathroom/f123-f148-f248 This page displays a floor plan, of which there are many. Currently, within each floorplan entry, you add the floors it ...
1
vote
1answer
51 views

Carousel with text using Matrix blocks

I am trying to create a carousel where each slide will have a title, subtitle, and maybe a summary. I know I can create a carousel like this with a set number of slides. I would like to create one ...
1
vote
1answer
92 views

Matrix block fields returning NULL when using MatrixBlock query

$blocks = MatrixBlock::find()->relatedTo($entry)->all(); The above returns the correct blocks but all fields are returned as NULL. I've read over at GitHub that we need to specify a fieldId ...