I'm trying to create a submission page at the following URL structure


As you can see /campaigns/ is the Channel and the /this-is-a-test-creation/ is the entry slug. I'm trying to currently set up my page using routing and fetch the related entry, but I'm having difficulties.

My route in the CP is set up as follows and works.


My code to fetch the relating entry doesn't

{% set entry = craft.entries.section('campaigns').slug('craft.app.request.getSegment(3)').one() %} {{ entry.title }}

This returns:

Impossible to access an attribute ("title") on a null variable.

1 Answer 1


Looks to me like there shouldn't be any quotes around craft.app.request.getSegment(3)

Also I'd use named parameters instead of .getSegment just seems a little bit more readable and robust.

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.