Skip to main content
5 votes

Matrix max block type limit

I just published a plugin called Limit Block Type, which adds the ability to limit Matrix blocks per block type. There's also a feature request for adding this feature to core.
Mats Mikkel Rummelhoff's user avatar
4 votes

Send a block... into a block?

It seems to be what you need is Twigs extend functionality. What you have here is a very common template structure so there is nothing out of the ordinary! Firstly, going from your code I'd recommend ...
Jamie Wade's user avatar
  • 3,644
3 votes
Accepted

Send a block... into a block?

Unfortunately, there's no way around having the {% block %} tag somewhere in the template that's being extended. In other words, your main layout template it's going to have {% block %} tags. However,...
Mats Mikkel Rummelhoff's user avatar
3 votes

How to programmatically add fields to matrix blocks?

I'm assuming that you're attempting to create the Matrix, with one or more blocks each containing one or more fields, from scratch? I.e. you're not simply trying to populate content into an already ...
Fuglsetrampen's user avatar
2 votes

Adding a new block type to Matrix causes subfields and subfields of other block types to disappear

Bumping php.ini's max_input_vars to a higher value as described in the answer here fixed it.
Jan Van Echelpoel's user avatar
2 votes

loop.last of a certain block type

To test if the current block is the last in the loop and of a certain type, you could do something like: {% if loop.last and block.type == "yourBlockType" %}yes{% endif %} or shorthand {{ loop.last ...
AbbeyDesign's user avatar
  • 1,527
2 votes

Using the Matrix field to output content in a slideshow

I think you'd be better off with your Matrix field, entry.homepageSlider having only one block type called Slide. This block type would then contain the fields for each slide such as slideHead, ...
Luke Pearce's user avatar
  • 3,863
2 votes

Using the Matrix field to output content in a slideshow

I reduced your code a little: You can use elseif to cycle trough each block so you don't have to write each if statement. Now where do you want your div? If you want each block with one separate div ...
KSPR's user avatar
  • 3,786
2 votes
Accepted

Matrix Field Conditional

Image are returned as an array so could use either of the following: {{ content.img[0].url }} Or set a variable which fetches the asset to then output its fields {% set asset = content.img.first() %...
Luke Pearce's user avatar
  • 3,863
2 votes

Generate a unique ID for each instance of a block from matrix field

You don't need unique IDs to do this. Just use the same class for all the blocks that you want to have your animation on. Then use an Intersection Observer to toggle the class once those blocks scroll ...
MoritzLost's user avatar
  • 11.3k
2 votes

block.type.handle Content Builder Matrix loop

This isn't ideal and reviewing your markup might be a better alternative but you could use the loop variable provided by Twig's for (docs). For you example, something like this should work {# Inject ...
Oli's user avatar
  • 7,495
2 votes
Accepted

Pull Matrix Block from Multiple Entries without Showing Duplicates

Assuming you can have multiple person blocks per entry (group), you could: Fetch your entries and eager-load the blocks and their entry to save some overheads {% set group = craft .entries() ....
Oli's user avatar
  • 7,495
2 votes
Accepted

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

You'll want to implement something like this: {% for block in entry.menuBuilder %} {% set type = block.type.handle %} {% set isFirstConsecutiveBlockOfType = (loop.first or type != block.getPrev()...
Jalen Davenport's user avatar
  • 3,045
1 vote
Accepted

Can not-related block types share a matrix field

It's not about performance or best practices, it's about your content structure. If you create one matrix field with two block types, both block types will be available everywhere that matrix field is ...
MoritzLost's user avatar
  • 11.3k
1 vote

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

Turns out my issue is because I am running 2 loops through entry.timeline: A subset of the field with only subsection blocks to generate a table of contents The entire field contents with a mixture ...
Jonathan Schofield's user avatar
1 vote
Accepted

craft.matrixBlocks element queries with .type()

This was a bug in a beta version of Craft 3 (fixed here: https://github.com/craftcms/cms/commit/9b6dad7385c5a82d1c83d230fe6ce0cfe940675b)
Matthias Redl-Mann's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible