I have a matrix with only one block type. and it only has videos ID's it (videoID).

I would like to have this videoID in the url and then fetch the corresponding Matrix Row.


That said: I know I could get the matrix row ID like this:

{% set test = craft.myMatrixField.id(craft.request.lastSegment()) %}
Video Id: {{ test.videoID }} 

But as the ID will change when reordering the matrix, I would like something more Permalink like and use the videoID in the URL.

Anybody knows how to achieve something like this?

1 Answer 1


Take a look at Craft's advanced routing. You'll need to define a regex pattern in order to create the named subpattern that you want, but once you've done that you can access the variable directly in your template.

In the following example {{ year }} and {{ month }} become available as variables in the news/_archive template

'news/(?P<year>\d{4})/(?P<month>\d{2})' => 'news/_archive',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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