1

I am trying to get a certain segment of the url. For this i’m setting the slug as a variable which seems to be best practice:

{% set slug = craft.request.getSegment(2) %}

I am interested in the second segment which is http://example.com/projects/awesome-project where “awesome-project” is the desired part.

I never had any problem with this method but in this case it always returns the first segment (projects), regardless of the passed argument. The site is localized.

I have tried various things but am completely clueless, atm. This can be reproduced with every template.

What could be the culprit?

1 Answer 1

2

Got it:

Had already set the slug variable to the first segment in _layout.twig thus overriding everything after. m(

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.