[SOLVED] How-to get the column setting of a column in a multicolumn layout

Hi everyone,

I want to access the column setting of a column in a multicolumn layout from a node inside the column. The information should be used to change rendering behaviour.

In my node’s fusion I have:

columnLayout = ${q(node).closest('[instanceof Neos.NodeTypes:MultiColumnItem]').property('columnLayout')}

And my modified multicolumn fusion contains:

prototype(Neos.NodeTypes:MultiColumnItem) {
	// columnLayoutMedium = ${q(node).parent().property('layoutMedium')}
	@override {
		columnLayoutLarge = ${q(node).parent().property('layoutLarge')}
		columnLayout = ${q(node).parent().property('layout')}

	columnLayout = ${columnLayout}
	columnLayoutLarge = ${columnLayoutLarge}

	attributes.class = ${'col-' + columnLayout + ' col-sm-' + columnLayoutLarge}

I can’t for the life of me figure out why I’m not able to access the information. Also trying to access the parent MultiColumn didn’t work.

Can someone point me in the right direction, please?

Regards, Jan

Hi Jan,
I think you might be confusing Fusion prototypes and Node Types a bit here.
First of all,

columnLayout = ${q(node).closest('[instanceof Neos.NodeTypes:MultiColumnItem]').property('columnLayout')}

will never give you anything. What you’re doing in your FlowQuery here is to read the closest parent nodetype that is of type Neos.NodeTypes:MultiColumnItem. However, there is no such node type - only a Fusion prototype that is essentially just a ContentCollection, so all it does is render the things inside the column.
The node type you’re looking for is Neos.NodeTypes.ColumnLayouts:Column, so your first query should be:

columnLayout = ${q(node).closest('[instanceof Neos.NodeTypes.ColumnLayouts:Column]').property('layout')}

Notice the changed property name: it’s “layout”, not “columnLayout” - you can have a look at the nodetype definition (in package Packages/Application/Neos.NodeTypes.ColumnLayouts/Configuration/NodeTypes.Content.Column.yaml and check that for yourself.

Secondly, it does not matter at all what you define in the Fusion prototype of your MultiColumnItem - any Fusion objects that get rendered by it cannot read those properties unless you pass them inside explicitly or put them in the context, which you haven’t done here. So essentially there are two way to get that layout from inside a rendered content prototype:

  1. Read it explicitly from the parent node, which is done by the Fusion above
  2. Get it set by the parent Fusion object’s context. You are not doing this in your second Fusion snippet, but it’s already done by default in the Neos.NodeTypes.ColumnLayouts:MultiColumn prototype. Have a look in Packages/Application/Neos.NodeTypes.ColumnLayouts/Resources/Private/Fusion/Root.fusion, and you will find this line: @context.columnLayout = ${q(node).property('layout')}. This makes the property “layout” from the Column nodetype available as a context variable named “columnLayout”. This means getting that from any Fusion prototype rendered inside is as easy as: columnLayout = ${columnLayout}

Hope that helps!

Thanks, that helped!
I’m still learning day by day…

No worries, glad I could help you. Understanding the distinction between node types and Fusion prototypes is probably the single hardest thing to get when you learn Neos, I still remember this from when I started :wink: