riegertoni
(Andreas Rieger)
June 14, 2017, 8:56am
1
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!
mficzel
(Martin Ficzel)
June 15, 2017, 9:14am
2
Your code has 2 misconceptions.
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
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}
}
riegertoni
(Andreas Rieger)
June 16, 2017, 8:46am
3
Thanks @mficzel ,
@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?
mficzel
(Martin Ficzel)
June 16, 2017, 10:01pm
4
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.