Questions tagged [block-types]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
22 views

Craft 3 Programatically Adding Block Types To Matrix

I have been attempting to programatically add blocks to a matrix field using the below code as part of a larger plugin learning project. use craft\fields\Matrix; use craft\fields\PlainText; //Create ...
2
votes
1answer
168 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 '...
2
votes
1answer
122 views

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

Update: Now I know the cause of my problem, I have appended to the original question title to try and help other people stumbling across the same issue. I have a pending support ticket open with P&...
1
vote
1answer
89 views

craft.matrixBlocks element queries with .type()

I'm using Craft Pro 3.0.0-beta.19 and I try to query matrix blocks with craft.matrixBlocks(). Background: I have event series (=structure) with a matrix block containing 1:n dates for each series. My ...
1
vote
1answer
47 views

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

When saving a newly added block type with subfields to an existing Matrix, the subfields of the new block type are gone and also are the subfields of 6 of the last block types. The whole Matrix ...
1
vote
1answer
349 views

loop.last of a certain block type

What are I doing wrong here? I'm setting block types 'stripCustom' and 'stripShowroom' to 'stripBlock' {% set stripBlock = entry.contentImage.type(['stripCustom', 'stripShowroom']) %} Then in a ...
4
votes
1answer
696 views

How to programmatically add fields to matrix blocks?

I am easily able to add a Matrix. I am also easily able to add a BlockType to that matrix. → I am fine so far. But I have no clue what I am missing when I try to add fields to my blocks using ...
3
votes
2answers
456 views

Using the Matrix field to output content in a slideshow

I want to use two block types in one Matrix field. These blocks will be output in a div. At the moment my code adds a new <div> for each block type. How can I output two block types in the same &...
1
vote
1answer
339 views

Matrix Field Conditional

I'm trying to attach a custom header image for each entry, if none is selected then the default one will be displayed. contentBuilder is the Matrix field. imgHeader is an assets block type. img is ...
2
votes
2answers
1k views

Send a block… into a block?

I'm fiddling around with Twig and CraftCMS, trying to create a component-based structure... of sorts. All good so far, except this one thing I got stuck on. Here's an excerpt from my main layout: &...
2
votes
1answer
714 views

Matrix - using Limit on block types

I'm using Matrix fields for blog posts. These are made up of text and image block types. I want to pull in only the first image block and a snippet of text from the first text block into the blogs ...
-6
votes
1answer
910 views

How to create custom blocks

We would like to create custom blocks. Is it possible to create custom blocks? if yes, do you have a good tutorial?
3
votes
1answer
383 views

Extending a block from another page

My orignal website is a Onepager but I am creating a individual news page. Is it possible to extend a block to another page taking over the content from that single? I have a block filled with a ...
3
votes
2answers
666 views

How do I select entries that have a particular block type?

Say I have a channel with a matrix field which has two block types - text and video. Is there any way to select all entries in that channel that have a video block? Idea 1 Use the Low Blocks plugin ...
2
votes
2answers
1k views

How to create code blocks with syntax highlighting

I'm deciding on the best way to have code blocks in my content. I'm doing something similar to Craft Docs. Do you have any best practices? Currently I'm thinking about having a matrix field for the ...
3
votes
1answer
610 views

Query for blocks across Block Types using the new field parameter?

This is a great new feature of Craft 2.3: It is now possible to set custom field parameters on Matrix block queries. I was wondering what would happen, if two or more Matrix Block Types had a ...
2
votes
2answers
702 views

Matrix max block type limit

Currently it's possible to set a max block value for the collection of block types. However I have a case where it would be great if I could set block type limit. For example I have a situation ...
3
votes
3answers
954 views

How can I get the last Matrix block of a certain type?

I have a Matrix field with some different block types; images, videos, text, etc. When I loop over the blocks I have some extra code (facebook and twitter sharing, back-button, etc) that should only ...
4
votes
2answers
282 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
296 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 ...
5
votes
1answer
251 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 ...
9
votes
2answers
843 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>{{ ...