I'm trying to make the jump from EE to Craft but struggling in this area (and thinking I may be approaching this all wrong).
In EE, I often use url segments (in combination with Freebie to ignore them) for certain logic in templates (ie. adding a last segment of 'thanks' to show a thank you message).
I cannot figure out how to do this well in Craft - or even if it is the right approach.
I have a channel entry with a slug of 'contact' and want to add 'thanks' to the url to conditionally display a thank you message on that page. I know I could add a route so that 'contact/thanks' will still load the correct template for that channel but I then run into the issue of that URL not matching the entry slug and no entry data is available for {{entry.whateverFields}}.
So then I did this to try to get around the issue by putting all my entry data in a for loop:
{% for entry in craft.entries.section('standard').slug(craft.request.firstSegment) %}
{{entry.title}}
...other template code in here
{% if craft.request.lastSegment == 'thanks' %}
...thank you message
{% endif %}
{% endfor %}
This lets me now get the correct entry data loaded for this entry (or others in this section) and my thank you message still appears however it just feels like an awkward way to do it and I suspect in other scenarios it could become really messy.
Is there a better way to approach this in Craft?
Or can you actually have Craft ignore certain url segments?