@context variables in Fusion

Hello,

I have a question regarding fusion:

I register a variable in context with:

@context.abc = ${this.var}

and use it to find a node:

testimage = Neos.Neos:ImageUri {
asset = ${q(node).find(abc).property(‘image’)}
maximumWidth = 2560
maximumHeight = 1280
@if.image = ${q(node).find(abc).property(‘image’)}
}

With ${this.var} i get a node identifier from a php class.

If try this snippet I get an error:
“Call to a member function getContext() on null”

What am I doing wrong?

Best,
Lucas

You didn’t show how this.var is generated. I guess there is your problem.

Thank you for your reply!
The php function is:

/**
*
* @return string
*/
public function getVar()
{
$entrytNode = $this->findMenuStartingPoint();
$this->var= “#”.$entryNode->getIdentifier();
return $this->var;
}

Note: var is just the placeholder for the variable name

I get the nodes Identifier as a string like this “#b1re54f-4f54f5e-frefred

And $this->findMenuStartingPoint() ?

Generally how do you use that PHP function? I think somewhere in that we will find the actual problem.

I extend the \Neos\Neos\Fusion\MenuImplementation class and I think $this-> refers the current node.

I guess that may explain it. Be aware that @context is set BEFORE the fusion object is actually executed, I guess that is the problem here.

Thank you this helped me a lot!