Replies: 10 comments
-
|
Not sure I’m following. Can you elaborate on your idea a bit? |
Beta Was this translation helpful? Give feedback.
-
|
Sure. Lets say we create route for user profile page - Next, we want to insert link to specific profile in templates - we have to create it like this: Then if we change route to for example If we had ability to give routes unique names, we could use them in templates using some kind of tag, like this:
Thats how it works in django. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for clarifying! |
Beta Was this translation helpful? Give feedback.
-
|
Related: #983 |
Beta Was this translation helpful? Give feedback.
-
|
Upvoted! There appear to be hints at this, within Yii (although, the routing in Craft is arguably much deeper than a basic CRUD app). Rails also has similar (but horribly opaque) “path helpers.” |
Beta Was this translation helpful? Give feedback.
-
|
I think this would be useful for Craft Commerce as well. I followed the (Commerce v1) example where the location of the templates determined the location of the store, then the client changed their mind about where the store should be located. I had to change my folder structure and references to the shop location. |
Beta Was this translation helpful? Give feedback.
-
|
@missmatsuko This might be a good use for Yii That said, I can sympathize with the litany of changes required to migrate whole groups of pages like this… my best recommendation here is to hide everything in your templates folder, and only expose some templates via <a href="{{ url(alias('@store/checkout')) }}">Checkout</a> |
Beta Was this translation helpful? Give feedback.
-
|
Right, I was going to suggest using aliases for this... seems like it solves the problem nicely. |
Beta Was this translation helpful? Give feedback.
-
|
This might be a little late, but i create workaround solution for named routes: |
Beta Was this translation helpful? Give feedback.
-
|
If anyone is interested, I just released a plugin that adds such functionality: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When we create routes and then want to use them in templates, we have to enter route structure manually in template file.
This is not DRY aproach because if for some reason we decide to change route url structure, we also have to change every part of template that used this route.
I propose adding slug field for each route and adding some kind of route template tag that would take in route slug as well as all route tokens. Kinda like url tag works in Django framework.
Beta Was this translation helpful? Give feedback.
All reactions