Skip to content

Using the value of a relationship fieldtype in collection routes #6650

Discussion options

You must be logged in to vote

You can workaround this by creating a Computed Value to return any related fields you want to use in your collection route.

For example, you could do something like this:

Collection::computed('locations', 'location_slug', function ($entry, $value) {
    return $entry->entries_field->slug();
});

Then, the collection's route would use that computed value like this: /locations/{location_slug}/{slug}.

If you want this to be supported in future version of Statamic, add a 👍 reaction to this feature request: statamic/ideas#360

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@duncanmcclean
Comment options

Answer selected by duncanmcclean
@hlorofos
Comment options

@duncanmcclean
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants