Skip to main content

Questions tagged [matrix]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
271 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 ...
Siebird's user avatar
  • 373
3 votes
1 answer
377 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 (...
ijust's user avatar
  • 163
1 vote
1 answer
465 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?
termi7e's user avatar
  • 23
1 vote
0 answers
41 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 ...
joomkit's user avatar
  • 2,034
1 vote
1 answer
83 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 ...
seth's user avatar
  • 117
1 vote
1 answer
209 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,022
0 votes
0 answers
91 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"...
MISC's user avatar
  • 1,019
1 vote
1 answer
74 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....
Jeffrey Q's user avatar
1 vote
1 answer
42 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 ...
Matt Wilcox's user avatar
  • 3,209
1 vote
1 answer
339 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', '...
Pete H's user avatar
  • 90
1 vote
1 answer
140 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 ...
richardpixel's user avatar
3 votes
1 answer
346 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 ...
Romain P.'s user avatar
  • 1,852
1 vote
1 answer
232 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 ...
Jason's user avatar
  • 107
1 vote
1 answer
595 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....
Thabang Chukura's user avatar
2 votes
1 answer
56 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/...
user2569's user avatar
  • 457
1 vote
1 answer
82 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 ...
richardpixel's user avatar
1 vote
1 answer
127 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 ...
Sandwich's user avatar
  • 636
2 votes
2 answers
405 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 ...
moondawg's user avatar
  • 333
1 vote
3 answers
967 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 ...
Sandwich's user avatar
  • 636
1 vote
0 answers
84 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 ...
jsun's user avatar
  • 113
3 votes
1 answer
1k 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) ...
evu's user avatar
  • 155
2 votes
1 answer
399 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 ...
Crafty Cat's user avatar
4 votes
1 answer
206 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....
Adam Menczykowski's user avatar
1 vote
1 answer
90 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)
ciso_gr's user avatar
  • 11
1 vote
1 answer
59 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 ...
Mvrcel Boer's user avatar
1 vote
1 answer
264 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 ...
Stephen's user avatar
  • 685
1 vote
1 answer
908 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 ...
Bryce's user avatar
  • 251
1 vote
1 answer
182 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 ...
Twain's user avatar
  • 160
1 vote
1 answer
338 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 ...
biko's user avatar
  • 670
4 votes
1 answer
462 views

Set SuperTableFields programatically

I'm trying to setup some Global fields in a migration. I'm using the SuperTable Field from verbb which is similar to a matrix field. I'd like to add several rows during migration but can't seem to ...
Piaras Hoban's user avatar
2 votes
1 answer
1k views

Matrix field not displaying all blocks on Craft 3 Upgrade

Just upgraded a website for the first time to Craft 3. I had a matrix field called bodyContent which is basically my page builder. Issue is not when creating new pages it the only blocks it seems to ...
mmc501's user avatar
  • 1,789
2 votes
2 answers
622 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()->...
Jeroen's user avatar
  • 308
4 votes
1 answer
435 views

Check if a field a included in a Matrix block

Situation: I have a matrix with about 10 block types, 3 of which have a certain field. I want to check if the current block has that field. The field in question is a dropdown with values in all 3 ...
Jan Henckens's user avatar
7 votes
3 answers
384 views

Create matrix block with no fields

Is it possible to create a matrix block with no fields? I'm using matrix as a page builder and have several scenarios where certain matrix blocks simply act as true/false checks. As an example, my ...
Joe B's user avatar
  • 146
1 vote
1 answer
180 views

Radio buttons in matrix field not saving

Craft CMS version 3.0.9 (updated from 3.0.1 to try and fix). I have a layout field in a matrix box with the radio buttons field type with the options normal (default), full, left, right. When saving ...
sput's user avatar
  • 31
1 vote
0 answers
61 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 %} ...
Mvrcel Boer's user avatar
1 vote
1 answer
168 views

Searching Matrix field

Can’t believe this is the first time I’ve had to do this, but I need to search a field inside a matrix and I can’t find any documentation on this. Craft 2 if that matters. I had hoped something like ...
Ian Ebden's user avatar
  • 894
1 vote
1 answer
2k views

How can I filter by Matrix field

I have a Matrix field and I want to be able to filter by it. For example I want to get all entries that has matrixField.field1Type.value = {some value}. How can I do that?
Камен Великов's user avatar
1 vote
1 answer
253 views

Match Matrix Fields Before Looping Through Results

I hope someone has an example or something similar they have done in Craft before. Her is what I have. Structure: Section -> Flight Company Matrix Name -> Plane Details Matrix Block: Plane Model ...
Vin's user avatar
  • 383
1 vote
1 answer
380 views

Craft 3: When querying for Matrix blocks in a plugin, how do you sort by a custom field?

My goal is to order an element query of Matrix blocks by a custom field. Any thoughts? namespace modules\mymodule\services; use Craft; use yii\base\Component; use craft\elements\MatrixBlock; class ...
Peter Tell's user avatar
  • 1,828
1 vote
0 answers
370 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 ...
Vin's user avatar
  • 383
1 vote
1 answer
1k views

Craft query Matrix blocks in twig

Is it possible to query elements of type MatrixBlock in Twig like other elements? You can get entries with {% set entries = craft.entries.all() %} Is there something similar available for Matrix ...
Vin's user avatar
  • 383
1 vote
1 answer
177 views

Internal Server Error: missing method or closure

Receiving the standard error: Craft\MatrixBlockModel and its behaviors do not have a method or closure named "sectionArticles". The problem is that this error doesn't make sense. Here is why: I ...
Jono's user avatar
  • 41
3 votes
1 answer
912 views

Search Through Matrix Field

Trying to search through a Matrix field, currently I am using conditionals to accomplish this, but if it's faster would like to limit the results to only what I need. {% for row in entry.matrixField....
Vin's user avatar
  • 383
2 votes
1 answer
210 views

Matrix Field Slug Output

I am not sure why, but I cannot seem to get the short name/handle/slug of a matrix field that is a category field. I need to get it's slug. {% for row in entry.matrixField %} {{ row.matrixChild....
Vin's user avatar
  • 383
2 votes
1 answer
176 views

Previous/Next button to next item in Matrix

I've made a projects structure with inside a couple of projects. On the homepage people can fill in a matrix with either a project or a textblock. I'm capable of looping through the detail pages in ...
Stef Dg's user avatar
  • 43
0 votes
1 answer
253 views

Sorting Matrix Field

I realize this is a very general question but is there a way to sort a matrix field? So not alphabetically but a very certain order.
Vin's user avatar
  • 383
2 votes
1 answer
727 views

Loop through matrix field find first block of a type

I'm trying to loop through a matrix field that has a few different types of fields in it and different orders. I want to first the first field of a certain type and output only that. Here is what I ...
Danielle Frappier's user avatar
3 votes
1 answer
621 views

Required alt text field in assets

I'm not sure if this is a bug or I'm doing this wrong. I have an asset volume called "Blog Images" and there is a custom required field called Image alt text. If I add images in assets section I'm ...
Danielle Frappier's user avatar
0 votes
1 answer
271 views

Fields (Matrix) side by side?

In ExpressionEngine it was possible to have fields side by side. So when creating a entry you had all options (for example for an image) in one row. I can't figure out how to do that in Craft
MrGlasspoole's user avatar

1 2 3
4
5
14