Combine classes from the link field and those passed in via getLink()
Closed this issue · 2 comments
What are you trying to do?
It would be good to have support to combining classes from the Hyper link field and those being passed in at a template level within getLink()
.
A use-case for this would be applying styling classes to a link in the template whilst allowing for additional class management for the link via the entry field.
At the moment adding classes to the link field overwrite the classes passed via entry.link.getLink({ class: 'btn' })
Example:
Link field classes: action-class
Template classes: btn
This will only add action-class
to the link.
What's your proposed solution?
Combine the class outputs so that it takes both into account so that the example scenario would output btn action-class
to the link.
Alternatively it would be good to have a setting in getLink()
which would either allow a combination of the classes or an override for the getLink()
classes, so that the combination can be managed at the template level as such
{{ entry.link.getLink({
class: 'btn' ~ (entry.link.classes ? ' ' ~ entry.link.classes)
}) }}
Additional context
No response
I'm doing something like this (which is working from 1.15):
{%- set class_list = "#{item.link_type.value}#{item.classes ? ' ' ~ item.classes : null}" -%}
{{ item.getLink({
class: class_list
}) }}
which gives me the default link-type class (link, text-link, button, ...) + whatever I pass in the templates.