[5.x]: New link field does not accept additional parameters for entries #15947
Closed
MatthiasBrodelet
started this conversation in
General
Replies: 1 comment
-
You could add the URL parameters directly in the template: {% if entry.myLinkField %}
{{ tag('a', {
href: url(entry.myLinkField.value, {
categories: 863,
currentAmount: 6,
}),
text: entry.myLinkField.label,
}) }}
{% endif %} Or you could add a new custom Text field for storing the query string params, and pull its value into the URL: {% if entry.myLinkField %}
{{ tag('a', {
href: url(entry.myLinkField.value, entry.myQueryStringField),
text: entry.myLinkField.label,
}) }}
{% endif %} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What happened?
Description
We are using the new link field and it saves us the time to configure something ourselves.
But now a client wants one of these link fields to point to an entry page but with the addition of some extra URL parameters which are used for filtering. In our case the URL looks like this => www.mydomain.com/en/resources?categories=863¤tAmount=6
How could this be achieved?
I can of course just hardcode it using the URL Link Type but we currently have this only on a staging site.
When the site goes live this needs to point to the live domain, not the staging domain.
I would hardcode it using the staging domain and when we go live use the find and replace functionality under "Utilities".
Feels a bit hacky but it does the trick.
The find and replace functionality also does not first show me all the matches it has found before actually replacing them so it really is a bit dangerous to use this.
Is there any better way to achieve this?
Craft CMS version
5.x
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
Beta Was this translation helpful? Give feedback.
All reactions