[SOLVED] Get variable of Custom Fusion Object in Fusion for use in fluid

Good morning,

I’d like to get a variable of a function of a custom fusion object class in fusion, so that I can use this variable in a fusion template.

For example my custom fusion object class looks like this:

namespace Vendor\Site\Fusion;

use Neos\Flow\Annotations as Flow;
use Neos\Fusion\FusionObjects\AbstractFusionObject

class GravatarImplementation extends AbstractFusionObject {
        public function evaluate() {
                $var = 'example';
                return $var;

And my fusion-prototypes like this:

prototype(Vendor.Site:Test) < prototype(Vendor.Site:Gravatar) {
		templatePath = 'resource://Vendor.Site/Private/Templates/FusionObjects/Test.html'
		test = Vendor.Site:Gravatar

prototype(Vendor.Site:Gravatar) {
		@class = 'Vendor\\Site\\Fusion\\GravatarImplementation'

My fluid template “Test.html” like that:

{namespace neos=Neos\Neos\ViewHelpers}
{namespace media=Neos\Media\ViewHelpers}


As expected, I can use {test} in fluid, so at the end ‘example’ is rendered - so far, so good.

My question is: How can I access the variable $var of the class GravatarImplementation in the prototype for a later use in fluid?
Something like var = Itoop.AlstaettertcDe:RawPosts::$var in the prototype, so that I can use {var} in fluid.
For a better understanding of my question: I’m looking for the opposite of $this->tsValue('__ts_value_key__');, so I don’t want to access values from Fusion in the class but the other way round.

I don’t know a way to pass variables to Fusion. But it seems you only need a value in a Fluid template. That’s easy. You have two possibilities:

First: just adjust your output in your evaluate() method (because you don’t use Fluid).

Second: If you use a Fluid template: If you extend AbstractFusionObject you have to create a Neos\Fusion\FusionObjects\Helpers\FluidView by yourself. If not, you extendend TemplateImplementation (which seems to be more likely, here)—that uses FluidView, too. FluidView inherits the method assign($key, $value). That method allows passing variables to Fluid Templates.
See https://neos.github.io/neos/3.0/source-class-Neos.Fusion.FusionObjects.TemplateImplementation.html#122-136 for an example.

What you want is not possible at least not how you imagine it. The question is, what is it that you actually want to solve? I am sure there is a good solution to that .

(Eg. return an array from the evaluate() of your FusionObject could be one way)

I misunderstood something; I don’t need to access variables for a later use in fluid in my usecase anymore.

I ended up in writing a small package for the integration of a facebook postlist: https://github.com/itoop/Facebook

Thanks for your advice!