Content Block field#17424
Conversation
# Conflicts: # src/config/app.php # src/web/assets/cp/dist/cp.js # src/web/assets/cp/dist/cp.js.map # src/web/assets/cp/dist/css/cp.css # src/web/assets/cp/dist/css/cp.css.map
# Conflicts: # src/web/assets/cp/dist/cp.js # src/web/assets/cp/dist/cp.js.map # src/web/assets/cp/dist/css/cp.css # src/web/assets/cp/dist/css/cp.css.map
# Conflicts: # src/web/assets/cp/dist/cp.js # src/web/assets/cp/dist/cp.js.map
|
This is gonna be great! 🎉 |
|
@brandonkelly I love this, thank you. When retroactively applying grouping to a bunch of existing fields (or matrix fields) used by many entries containing data already, is there any straightforward way to migrate the data? |
|
@trijammer You can copy top-level field values into a Content Block field using php craft resave/entries --set myContentBlockField \
--to "fn(\$entry) => ['fields' => ['subFieldA' => \$entry->fieldA, 'subFieldB' => \$entry->fieldB]]"Or if the data is already nested within a Matrix field with Min/Max Entries set to php craft resave/entries --set myContentBlockField \
--to "fn(\$entry) => ['fields' => ['subFieldA' => \$entry->matrixField[0]->fieldA ?? null, 'subFieldB' => \$entry->matrixField[0]->fieldB ?? null]]" |
|
Question not specifically related to the Content Block field, but @brandonkelly is there a way to have the native alt text field display alongside Asset fields without having to do something like like the first example here? It would mean my content editors are a lot more likely to fill out the alt text field if it was right there and they didn't have to go to the asset. |
|
@BenHMatrix Yep, you can choose to have assets’ alt text included in their card view (from the volume’s settings), and set your Assets field to show the cards view. |
|
With multiple "Content blocks" support for the same entry this would be perfect ❤️ |
+1! |
Description
Adds a new “Content Block” field type, which provides a nested field layout that can be pulled into other element types’ field layouts.
There’s also a “View Mode” setting, which determines how the content block layout should be presented within parent field layouts:
When “Inline” is selected, nested fields will appear right alongside other fields in the parent field layout, without any obvious indication that they’re associated with a nested element.
Development
To access field values within a Content Block field, prefix them with the Content Block field’s handle:
{{ entry.myContentBlockField.myNestedField }}Ditto for GraphQL:
Related issues