Questions tagged [matrix]

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

Filter by
Sorted by
Tagged 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="...
2
votes
1answer
2k views

Array to string conversion Template Error

I have 2 bits of code that should be about identical with the exception of one being in a Matrix and one not. The bit that is not looks like this: <ul> {% for point in entry.keyPoints %} ...
3
votes
2answers
746 views

Gallery block inside a Matrix

What's the best solution for having a 'gallery' block inside of a Matrix? By 'gallery block' I mean an ability to have multiple images, with captions, alt, and link, presented as a gallery on the ...
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-...
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 ...
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 ...
7
votes
4answers
1k views

Matrix field alternative (or easier field grouping)

Just started working with Craft, and it's been great! One question I have is regarding the 'correct' way to create a group of fields, rather than using Matrix or Table. To better illustrate, see the ...
11
votes
3answers
1k views

Programatically create a Matrix field

I'm developing a plugin which requires certain sections and fields to exist so I'm currently creating them in the onAfterInstall() method of the plugin. I can create individual fields, sections, ...
4
votes
2answers
286 views

How to output the matrix block type name in Craft? Possible feature request

Is it possible to output the block type name in Craft for each matrix block in your field? Currently Craft just lists the name of each field within the block, but we are using generic field names (...
2
votes
1answer
763 views

MatrixBlockModel error - “Call to a member function on a non-object”

I'm having some trouble trying to write a plugin. I'm trying to create a simple fieldtype that I'm going to use inside a matrix block. So far the public function getInputHtml of my fieldtype class, ...
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 ...
3
votes
2answers
111 views

How to integrate an image haystack replacement technique

I'd like to use a tokenised image replacement technique which is commonly adopted in ExpressionEngine. This is where the author can add image tokens such as {image_1}, {image_2} etc into their content,...
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....
2
votes
1answer
516 views

Create a variable from content in a matrix field

I want to create a variable based on the contents of a matrix block. This is the code I created: {% for item in entry.screenshot %} //my matrix field {% for asset in item.webpage %} // an asset ...
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 ...
2
votes
1answer
2k views

Checking if a matrix field with entries has more than one entry

In my HTML-prototype I have two ways of showing a module of employees. One version shows one employee, and the other shows two. To build this in Craft I have setup a Matrix field (with a handle ...
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 ...
2
votes
1answer
188 views

Return all Matrix blocks with a drop down set to a specified value

I'm in the context of an Entry that has a Matrix field, and one of those Matrix fields is a Dropdown called subsection. I want to grab all Matrix blocks that have subsection set to 'intro'. This is ...
8
votes
1answer
2k views

How do you filter matrix blocks by type?

Is there a way to filter a matrix by block type, or get a count of how many items there are of a certain type? Can't find a syntax example. I created a matrix with two blocks. In pseudo code, ...
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 ...
13
votes
6answers
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 ...
2
votes
1answer
2k views

Looping through a Global with a Matrix field

This might be a very simple question but I am pretty new to Craft with a EE background. Basically, I have a global containing contact details that use a matrix field, I’m literally just looking for ...
4
votes
3answers
899 views

Return specific Matrix row?

I'm looking to be able to return the info from a field(s) from a Matrix row where I know which row I want (long story). I had a guess at various ways of doing this, but in the end the only way that ...
3
votes
2answers
475 views

How can I list all sub-field handles of a Matrix parent field?

If I want to get a list of all fields that I've defined on the site, I can do this: craft()->fields->getAllFields() But how do I get a list of all sub-fields defined within a Matrix field? I ...
5
votes
4answers
2k views

How to order by matrix field?

I have a section where its entries have a matrix field (matrixField). In the first matrix block there is a date field (dateField). I want to get my entries ordered by that date field. Is this possible?...
2
votes
1answer
161 views

Matrix getBlockTypesByFieldId() function doesn't work as intended? [closed]

One of the functions in a plugin that I'm working on, is the ability to create fields. It has created a Matrix field, and directly after that, I want to know the MatrixBlockType. I don't get any ...
1
vote
1answer
1k views

Can I get Assets from a specific Matrix block?

When they exist, I'd like to get specification PDFs from a product entry. They're stored in a productInfo Matrix field, in a specifications block that has a downloads Assets collection. Naturally I ...
2
votes
1answer
303 views

Is it possible to share a field between Matrix Blocks?

I'm attempting to do some advanced layout orchestration using Matrix blocks. I'll need different blocks types – Image, Quote, Body – that can be combined, but they'll each need to share a few fields ...
6
votes
1answer
363 views

Return entry where matrix field is not empty

I am trying to get a random entry which has the quote matrix field populated. I've tried this: {% set entry = craft.entries.section('entries').quote(':notempty:').order('RAND()').limit(1) %} That ...
5
votes
1answer
260 views

Is there a way to hide Matrix blocks based on the Selected Entry Type?

I have 2 primary entry types, one for a full width page, and one for a sidebar page. The sidebar page shares about 90% of the same block types as the full width page. The other 10% do not apply to ...
5
votes
2answers
418 views

Is there a way to populate a drop-down with the templates files in a folder?

When I have a folder setup for template partials, is there a way I could automatically populate a drop-down with the list of templates in that folder? This would be useful in the case where I have a ...
14
votes
2answers
2k views

How can I return data from a Matrix field in random order?

I have a slideshow with slide data managed in a Matrix field. How would I go about randomizing the data returned in the template so the slides show in a different order on each page load?
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?
9
votes
2answers
875 views

Is it possible to output the name of a Matrix Block?

I'd like to output the Names of Matrix Blocks. I know you can filter by block types e.g. {% for block in entry.myMatrixField.type('text, heading') %} {% if block.type == "heading" %} <h3>{{ ...

1
8 9 10 11
12