Hi,
I’m trying to add social media buttons to my page. To reduce redundancy I’d like to define some properties separately and inherit them afterwards:
Services.fusion
commons {
// Assigns node uri to the shareUri property in order to process it later
shareUri = NodeUri {
node = ${documentNode}
absolute = true
}
// Encode node uri
shareUri.@process.encodeUri = ${String.rawUrlEncode(value)}
shareText = "Share this"
}
serviceFacebook < commons
serviceFacebook {
serviceName = "facebook"
renderName = "Facebook"
// Join service share uri and node uri {value}
shareUri.@process.addServiceUri = ${'https://www.facebook.com/sharer/sharer.php?u=' + value}
}
serviceGooglePlus < commons
serviceGooglePlus {
serviceName = "google plus"
renderName = "Google Plus"
// Join service share uri and node uri {value}
shareUri.@process.addServiceUri = ${'https://plus.google.com/share?url=' + value}
}
Prototype
prototype(Social.Media:Buttons) < prototype(Neos.Neos:Content) {
services {
facebook < serviceFacebook
gplus < serviceFacebook
}
}
Fusion template
<div class="ui buttons">
<f:for each="{services}" as="service">
<f:link.external uri="{service.shareUri}" class="ui {service.serviceName} button"><i class="{service.serviceName} icon"></i>{service.shareText}</f:link.external>
</f:for>
</div>
The first button gets rendered as expected but the second doesn’t. It seems that serviceCommons
is empty after serviceFacebook
inherited it.
If I add {service -> f:debug()}
in the for loop rendering the page gets caught in an infinite loop rendering the debug information for prototype(Social.Media:Buttons).services.facebook
because its the first property that gets rendered.
Is it not possible to inherit more than once? What needs to be changed in order to keep things used more than once separate?
Regards