Hi everyone!
I’m trying to create an element. This element has a property that lets you select another page or a link, and if this link is set a button shows. I’m trying to get this button to get the right href, but I can only seem to get the node_id inside it.
I get the Id I want to translate into URI like this.
link = ${q(node).property(‘link’)}
Nothing, special there. I’ve looked into the documentation and I’ve found this:
Neos.Neos:ConvertUris
So I go like this:
link.@process.ConvertUris = Neos.Neos:ConvertUris {
value = ${link}
}
I’ve tried other solutions but I can never get the right URL, it is either empty or I get an error message saying I need to put a node not a string.
I don’t know if it has something to do with this but This property is passed down to another element
If it is a “string” property and uses the LinkEditor links for nodes will uses the protocol node://__identifier__ that you can use with Neos.Neos:ConvertUri as in your code above.
link = ${q(node).property('link')}
link.@process.convertUris = Neos.Neos:ConvertUris
If your the type of the link property is “reference” the stored value is the node itself. That is converted to a nodeUri like so:
link = Neos.Neos:NodeUri {
node = ${q(node).property('link')}
}
Thank you very much for your reply Martin, it was very helpful,
I was missing the type of link’s property, I’ve tried both methods that you’ve suggested and with the property set as reference it works!
I just get this error now, on neos’s backend where the link property should be
“TypeError: Cannot read property ‘startsWith’ of null”
The property was a reference to another page, on the front-end the link works, But now i can’t change the reference node.
I’ll try to make it work in the meantime
Thanks again !
Update: It didn’t like the name “link” as a property name.Changed it to link reference. But now Even when this property is empty of the front end I still see the link, pointing to what I set it before emptying the property. Trying to figure this one out now
Update 2: Ok It doesn’t switch back to what I selected before, it points to the current node, this in not a behaviour that I want
Ok I’ve fixed everything. There were a couple of added requests, but I’ll post the solution just in case someone Stumbles upon this post in the future:
You can put if else inside neos Case statements (I didn’t know that was possible) inside the fusion