[SOLVED] Verify in fluid if nodeType is type of XY

Hello
I have a fluid-temlpate within I verify if nodeType.property.xy is set to «true» with

<f:if condition="{node.properties.xy} == 'TRUE'">

Is there also a verify-possibility against the nodeType itself?
something like

<f:if condition="{node.type} == 'TYPO3.Neos.NodeTypes:Title'">
  1. Would be great if someone would have a solution for.

  2. Is there somewhere a list about all fluid-inline usable attributes or could I find this somewhere in the source?

You can access all public properties and getter methods (just omit the () braces when calling from fluid)That being said, this sounds like something that would be better placed in TS/Fusion instead of Fluid.

Thanks Bastian,
Yes normally I would check in Fusion. But in this particular situation (iterator template: changed in post above) it is easier to check while iterating …

  • I have problems to find the getter methods? Are this viewHelpers?
  • And with public properties you mean the properties of the particular iterated node? Are there sometimes private or protected in default neos-system. Or do you mean something else?

Tried to chose the ViewHelper getType. But obvious this is only to check Array-Elements (I guess). Doesn’t work.

Hi,

as Bastian (the other one *g) already mentioned: You probably want to avoid such lowlevel logic in your templates.

true and false are keywords in Fluid so you could do:

<f:if condition="{iteratorElement.properties.xy} == {true}">

In general your approach should work. Except that iteratorElement.type is probably an instance of NodeType not a string. Try

<f:if condition="{iteratorElement.type.name} == 'TYPO3.Neos.NodeTypes:Title'">

The “inline notation” is a general Fluid feature, all ViewHelpers and all arguments can be used inline, for example the above could be written as

{f:if(condition: '{iteratorElement.type.name} == \'TYPO3.Neos.NodeTypes:Title\'', then: 'is title', else: 'is not')}

See related post from Peter

Hey, thank you for:

Sorry, but

<f:if condition="{node.type.name} == 'TYPO3.Neos.NodeTypes:Title'">

does not work in my installation.

Tried to look with debug:

<f:debug>{node.type.name}</f:debug> // get NULL

<f:debug>{node.type}</f:debug> // get NULL

On the other hand

<f:debug>{node.properties.xy}</f:debug> // get the value

<f:debug>{node.properties}</f:debug> // get the Array

<f:debug>{node}</f:debug> // get a big list about everything

Maybe I misunderstood something? Or what could be wrong? «type» and «name» are not Placeholders or are they? Cold also not find a solution in linked post.

Well, it depends on the type of “iteratorElement” (not the most declarative name IMO).
That “big list about everything” would be interesting :wink:

If it’s a node (implementing NodeInterface) the property you are looking for is called nodeType not just type

Great! It works!

You are right.

At beginning I named it «nodeTypeName» but after Bastians response I thought it could be misunderstood, because it is in a iterateor-Loop. So hope the third try will match better: changed it to «nodeTypeInIteration» also for better “searchability”.


Silly: I have analyzed the debug-output before I wrote the topic. Have seen the nodetype property and also tried it. But get an infinitely long output. At the end really simple: «name» attached and it rocks.


NodeInterface?

Have used google and riffle through SourceCode (2697 matches) but can't find an good startpoint for use Neos' NodeInterface. Is this the Object/Interface where Bastian's «properties» and «getter-methods» are from?
  • Is there a recommended starting point (root-file) to get in? Or a documentation about?

It’s just a node (implementing NodeInterface) and as such it has a getter getNodeType() (returning an instance of NodeType). So why not just call it “node”:

<f:if condition="{node.nodeType.name} == 'xyz'">

and or

{node.nodeType.name -> f:debug()}

Changed :wink: – Thanks!