4

I'm trying to use global variables in Entry URLs generated by Craft, but they seem to be empty. Not getting any errors as such, just null.

My Entry URL format looks like this:

{{siteDefaults.artworksList.first.uri|default}}/{slug}

Where artworkList is an entry with a URI/URL but I'm getting "/some-entry-slug"

Similarly, {{siteDefaults.artworksList.length}} returns 0 even though there is an entry there.

Has anyone tried to use globals before in entry URLs?

Thanks!

Johan Douma
  • 165
  • 1
  • 7

1 Answers1

5

Your CraftCMS global can be accessed using the code

{{craft.globals.getSetByHandle('siteDefaults').artworksList.first.uri|default}}/{slug}

I believe the issue is that the Entry URL field requires you to use craft.globals to prevent issues with the routing custom variables.

Regan Lawton
  • 161
  • 5