Path to a node to be used as form action

Hi Guys,

Currently I’m struggling with retrieving the document node path to the page where the search form (Flowpack.SimpleSearch.ContentRepositoryAdaptor:Search) is used. I want to use this as the action URL for a site wide search form.
I tried different variations of:
foo = ${q(site).find(’[instanceof Flowpack.SimpleSearch.ContentRepositoryAdaptor:Search]’).parent(’[instanceof Neos.Neos:Document]’).get()}
bar = ${String.toString(foo)}

I don’t get it. Any suggestions?

Thanks in advance!

Your code has 2 misconceptions.

  1. The node path is not the uri - it is the path in the content-repository to get the node uri you can use Neos.Neos:NodeUri fusion object as documented here http://neos.readthedocs.io/en/stable/References/NeosFusionReference.html#nodeuri

  2. You cannot access a fusion property on the same level just by name. You have to add this or put the referenced property into the @context

In total i think this should work … but i did’nt test

@context.targetNode = ${q(site).find('[instanceof Flowpack.SimpleSearch.ContentRepositoryAdaptor:Search]').parent('[instanceof Neos.Neos:Document]').get()}
actionUri = Neos.Neos:NodeUri {
  node = ${targetNode}
}

Thanks @martoro,

@context was the hint. I had to wrap ‘targetNode’ into a query, otherwise ‘node’ would default to the current documentNode. Now it works!

Here the full fusion code:

prototype(My.SitePackage:SearchForm) < prototype(Content) {
	templatePath = 'resource://My.SitePackage/Private/Fusion/Components/SearchForm/SearchForm.html'
	@context.targetNode = ${q(site).find('[instanceof Flowpack.SimpleSearch.ContentRepositoryAdaptor:Search]').parents('[instanceof Neos.Neos:Document]').get()}
	actionUri = NodeUri {
		node = ${q(targetNode).get(0)}
	}
} 

BTW: Why do I have to use get(0) instead of simply get() here?

The result of get() is always an array. Since flowQueryContext always is an array. q(node) just creates a context that has just one item.