Skip to main content
6 votes
Accepted

How to pull the first block of its kind from a Matrix?

You could try something like this: {% set block = post.buildStory.type('textEditorBlock').first() %} {{block.textEditor}}
alexr's user avatar
  • 628
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

Is there a way to define a global var within a twig block?

This article may help as well: Twig Processing Order & Scope
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Can I use a Block inside an Include file?

I believe it is possible @jack. Take a look at this working demo - http://twigfiddle.com/9rwjeo Update: On closer inspection the original example did not work. You can not have a block inside an ...
Fyrebase's user avatar
  • 735
3 votes
Accepted

What's the difference between Neo and Matrix fields?

On first blush they are very similar. I think the Craft Plugin Store description of Neo sums it up nicely: Neo is a field type that builds upon the concept of the Matrix field type with a number of ...
RitterKnight's user avatar
  • 6,582
3 votes
Accepted

Using a variable that was set in a previous include

So what you're running into is Twig scoping rules, which is discussed at length in the article Twig Processing Order & Scope The TL;DR is that a variable is only available in the context in which ...
andrew.welch's user avatar
  • 11.6k
2 votes

Migrating Content from ExpressionEngine that used Matrix Image haystack Technique

You have two main options with a challenge like this. 1) Do it manually - While this option doesn't always sound like the most glamourous option, it's often a fairly reasonable step to consider ...
Ben Parizek's user avatar
  • 13.5k
2 votes
Accepted

Exclude a block from appearing on a specific page

You can check against the Entry Type as well. I would try to validate it with something like: {% set exclusions = ['home'] %} {% if entry.type not in exclusions %} ....
Jon Tastemel's user avatar
2 votes
Accepted

Nesting block tags doesnt work

Unfortunately it’s not possible for an included template to override the contents of a block in the parent template, or its layout. You’d need to just override the seo block from page.twig do ...
Brandon Kelly's user avatar
2 votes
Accepted

How to handle client expectations regarding page building and layout within Craft

This question comes up in support tickets every so often from client users. We like to say that Craft fills the space between where WordPress ends and Enterprise begins. It's meant for designers and ...
Sam Hernandez's user avatar
2 votes
Accepted

pass block into embed and forward to another embed?

If partial_with_form.twig isn’t making any of its own customizations to form.twig, then I’d just include the form.twig template using an {% include %} tag, and wrap that whole thing with a {% block %},...
Brandon Kelly's user avatar
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

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.6k
2 votes

Programatically add new neo blocks without overwriting manually made one

First, get values of existing block and append with values of new block and update with looping neo field blocks one by one.
Kishore Natarajan's user avatar
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
1 vote

Change order content blocks home page

As you can see from the screenshot below and as Oli already mentioned, you can simply drag the content blocks on a page and hit the save button. That said, this is possible with contentblocks that are ...
MisterMike's user avatar
1 vote

Change order content blocks home page

By default, Matrix blocks will display in the order you have entered them in your entry form. If you need to change the display order, you can drag/drop your blocks straight from your entry form using ...
Oli's user avatar
  • 7,495
1 vote
Accepted

Order matrix blocks by date field

I hope I am not completely missing the point, but I guess like that: Initial 5: {% for block in block.eventList.eventDate('>=' ~ (now|atom)).orderBy('eventDate asc').limit(5).all() %} {{ ...
Matthias Redl-Mann's user avatar
1 vote

pass block into embed and forward to another embed?

Hm, seems like you can use block() but it can't be within the embed block. Putting it in a variable first and use that variable in the embed block works. {% set petition_after_fields_block = block('...
jishi's user avatar
  • 273
1 vote

Counting included child blocks in the Neo plugin

The answer by Tom Bauer given to my question here should be of help. You're not far off. You need to set a variable and count the blocks in your neo loop. Then use if statements in the loop depending ...
lucaslink's user avatar
1 vote
Accepted

Display text field from Matrix of an Entry Field in Matrix

There's a couple of problems with your current code – for one, you're (as Brad mentions in the comments above) doing some variable overwriting by reusing the entry and block names. Also, you're ...
Mats Mikkel Rummelhoff's user avatar
1 vote
Accepted

Include user information in html block

There is a currentUser global variable that is available to all Twig templates. If there is a currently logged in user, it will return that user's UserModel class. From there, it's just a matter of: ...
Brad Bell's user avatar
  • 67.5k
1 vote

How to pull the first block of its kind from a Matrix?

You could do: {% set blocks = post.buildStory.type('textEditorBlock').limit(1) %} Also, not your question, but this hacksaw port is great for those teasers. Has some extra logic to make those a ...
sgtpenguin's user avatar
1 vote

Matrix entry causing last bootstrap column to be shunted down

This issue won't be related to the Matrix field or the twig tags outputting it - check the CSS thats being applied. Are you wrapping your columns in a div with a class of .row? UPDATE: test by ...
Luke Pearce's user avatar
  • 3,863

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