Skip to content

Instantly share code, notes, and snippets.

@keithmancuso
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithmancuso/58347c0e886e382bdd26 to your computer and use it in GitHub Desktop.
Save keithmancuso/58347c0e886e382bdd26 to your computer and use it in GitHub Desktop.
City switcher
{% set newUrl = '' %}
{% for segment in craft.request.getSegments() %}
{% if loop.index == 1 %}
{% set newUrl = newUrl ~'/'~ city %}
{% else %}
{% set newUrl = newUrl ~'/'~ segment %}
{% endif %}
{% endfor %}
{% set segments = craft.request.getSegments() %}
{% set newUrl = segments[2:segments|length] %}
{% set newUrl = city.slug ~ newUrl %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment