I'm using this plugin/fieldtype

https://github.com/sebastian-lenz/craft-linkfield v1.0.25

on Craft 3.7.61. When I try to output some of its values, for example:

{{ item.button.getUrl() }}

I get no result. I am able to output:

{{ item.button.getText() }}

without issue.


When I dump a field having an external URL, I get the expect value:

^ typedlinkfield\models\Link {#4461 ▼
+ariaLabel: null
+customQuery: null
+customText: "versa"
+target: ""
+title: ""
+type: "url"
+value: "https://versastudio.com"
-prefetchedElement: null
-linkField: typedlinkfield\fields\LinkField {#4101 ▶}

When I dump one with a Craft entry, I get the entry ID.

^ typedlinkfield\models\Link {#4352 ▼
 +ariaLabel: null
 +customQuery: null
 +customText: "Hello"
 +target: ""
 +title: ""
 +type: "entry"
 +value: "48328"
 -prefetchedElement: null
 -linkField: typedlinkfield\fields\LinkField {#4118 ▶}

And I am unsure how to then get the URL for a simple link.

2 Answers 2


It's impossible to tell what's going wrong there without additional information. Your code is correct, and it's unlikely that there's a bug causing this basic feature to not work correctly. Try dumping the button field to see if it actually contains a URL:

{% dd item.button %}

If it doesn't, make sure your field actually contains a URL in the backend – are you maybe looking at a draft in the backend, but at the live version of the entry in the frontend?

If it does, try {% dd item.button.getUrl() %} – if this shows the URL, the issue is probably something else in your template.

  • I edited my Q to reflect dumped values, could you have another look?
    – 4midori
    Commented Apr 18, 2023 at 1:11
  • @4midori Hm, curious. Based on the dumps and your code, everything should work as expected. Are you able to update to the latest Craft 3.x or 4.x release, just to see if it's a bug that's already been fixed? I still think the most likely issue is something related to the templates. For example, something in your CSS causing the link to be invisible, or maybe you're seeing the cached output of your template? If none of those help, you could open an issue on GitHub for this, maybe it really is a bug in the plugin.
    – MoritzLost
    Commented Apr 18, 2023 at 7:33

At some unknown point, there was a change in the way this plug-in works. The output of getUrl() only works for certain types of links. If the link is an entry or asset, the ID is returned instead.

So I did this:

          {% switch column.button.type %}
            {% case 'entry' %}
              {% set theUrl = craft.entries().id(column.button.value).one().url() %}
            {% case 'asset' %}
              {% set theUrl = craft.assets().id(column.button.value).one().url() %}
            {% default %}
              {% set theUrl = column.button.getUrl() %}
          {% endswitch %}
  • I don't think that's the normal behaviour. getUrl() has always returned the URL and still does for me (on 2.x).
    – MoritzLost
    Commented Apr 19, 2023 at 7:33
  • Do you mean Craft 2.x? I'm on 3.x.
    – 4midori
    Commented Apr 19, 2023 at 21:13
  • @midori I mean 2.x of the plugin – that's the branch for Craft 4, 1.x is for Craft 3. Are you seeing the same issue with other typed link fields? In other templates, or even on other sites?
    – MoritzLost
    Commented Apr 20, 2023 at 9:34
  • I'm using the 1.x branch for Craft 3. I just installed the plugin on a Craft 4 site, and the syntax has changed there, the plugin works better too.
    – 4midori
    Commented Apr 20, 2023 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.