Answers.Body: <p>I'm not sure to understand what you're trying to solve but... have you tried using the <a href="https://craftcms.com/docs/plugins/hooks-reference#getElementRoute" rel="nofollow noreferrer">getElementRoute</a> hook to bypass the default Craft routing and apply any custom processing/routing you need?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-28T16:46:11.103Z
Answers.Text: looks interesting. that may work. do you mind providing more detail on where exactly i would use this hook and how i would use it for multiple 'outlying' channels? ie- would i need to hardcode it for each? put them all in one array inside the hook? thanks.
Answers.UserDisplayName: userAW
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-28T17:17:02.937Z
Answers.Text: and this is what i'm trying to do: http://craftcms.stackexchange.com/questions/9093/linking-to-channel-via-structure-section?rq=1 but i need to link the urls the main structure and its outlying structures/channels, preferably in a dynamic manner
Answers.UserDisplayName: userAW
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-02T17:49:36.777Z
Answers.Text: I've changed my mind and decided that urls should not be dynamically set in the site, since I'd prefer to separate system config/data architecture and site output. If we set dynamic urls from the get-go later down the road we will likely regret losing the flexibility of setting urls for each section as whatever is most intuitive/best for SEO, etc. i have not tried your suggestion (nor do i understand it fully) but if anyone else tries it, please comment below to make this question more helpful to others. Thanks for your help.
Answers.UserDisplayName: userAW
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-28T14:35:35.513Z
Answers.LastActivityDate: 2017-02-28T14:35:35.513Z
Answers.UserDisplayName: gioppe
Body: <p>I'm trying to create dynamic urls for a channel or structure section that depend upon the url structure of a different structure (or the first entry in that structure). For example, if the main structure has "foo.com/news/" I want the 'news' channel entries to have urls of "foo.com/news/{slug}". </p>
  
  <p>I came across this question/answer which seems like a great solution: <a href="https://craftcms.stackexchange.com/questions/1516/dynamically-setting-a-channels-entry-url-format-with-craft-tags">Dynamically setting a channel&#39;s Entry URL Format with Craft tags</a>  However, like mentioned it's not really dynamic as you need to go back and resave if the parent slug changes. I started doing this and it's turning into a disaster. </p>
  
  <p>Has anyone found a way to do this completely dynamically? Would routing be the right way and how would it be done (I have not used routing)? Or backwards relational entries from the channel to main structure (which seems much less intuitive from CP UI perspective)? </p>
  
  <p>...and if you don't have any ideas, HOW do you deal with urls when you have a 'pages' structure and linking from that to a channel? Based on extensive research, this seems to be the best way of blending structures and channels but my site is too large and complex to hard-code the url structures for the outlying channels/structures. </p>
  
  <p>I don't have the rep to comment on the post above, hence the new question. Thanks much in advance! </p>
  
  <p>****See my comment below gioppe's answer. I have decided against using this dynamic url approach, as explained in my comment.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-15T22:57:29.930Z
Comments.Text: I am after the same thing... Almost 3 years :) Did you maybe stumble over the solution?
Comments.UserDisplayName: outline4
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-16T13:16:52.707Z
Comments.Text: No. Read my comment below. I decided that it was a better long-term solution to set the url structures manually so that we would have the option of deviating from our standard setup when needed for SEO and usability.
Comments.UserDisplayName: userAW
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-16T19:44:06.377Z
Comments.Text: OK thanks... I'll have to dig into this myself... This question has been asked many times without a solution that would fit me...
Comments.UserDisplayName: outline4
Tags: <url><structure><channels><craft-features>
Title: dynamic urls for channel/structure that's linked to the main structure
ThreadText: # dynamic urls for channel/structure that's linked to the main structure
  
  (Asked by: username_0 on 2017-02-28)
  
  I'm trying to create dynamic urls for a channel or structure section that depend upon the url structure of a different structure (or the first entry in that structure). For example, if the main structure has "foo.com/news/" I want the 'news' channel entries to have urls of "foo.com/news/{slug}".
  
  I came across this question/answer which seems like a great solution: [Dynamically setting a channel's Entry URL Format with Craft tags](https://craftcms.stackexchange.com/questions/1516/dynamically-setting-a-channels-entry-url-format-with-craft-tags) However, like mentioned it's not really dynamic as you need to go back and resave if the parent slug changes. I started doing this and it's turning into a disaster.
  
  Has anyone found a way to do this completely dynamically? Would routing be the right way and how would it be done (I have not used routing)? Or backwards relational entries from the channel to main structure (which seems much less intuitive from CP UI perspective)?
  
  ...and if you don't have any ideas, HOW do you deal with urls when you have a 'pages' structure and linking from that to a channel? Based on extensive research, this seems to be the best way of blending structures and channels but my site is too large and complex to hard-code the url structures for the outlying channels/structures.
  
  I don't have the rep to comment on the post above, hence the new question. Thanks much in advance!
  
  \*\*\*\*See my comment below username_2's answer. I have decided against using this dynamic url approach, as explained in my comment.
  
  **Tags:** url, structure, channels, craft-features
  
  > **Comments:**
  > **username_1**: I am after the same thing... Almost 3 years :) Did you maybe stumble over the solution?  
  > **username_0**: No. Read my comment below. I decided that it was a better long-term solution to set the url structures manually so that we would have the option of deviating from our standard setup when needed for SEO and usability.  
  > **username_1**: OK thanks... I'll have to dig into this myself... This question has been asked many times without a solution that would fit me...  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-02-28. Score: 1 | Accepted answer
  
  I'm not sure to understand what you're trying to solve but... have you tried using the [getElementRoute](https://craftcms.com/docs/plugins/hooks-reference#getElementRoute) hook to bypass the default Craft routing and apply any custom processing/routing you need?
  
  > **Comments:**
  > **username_0**: looks interesting. that may work. do you mind providing more detail on where exactly i would use this hook and how i would use it for multiple 'outlying' channels? ie- would i need to hardcode it for each? put them all in one array inside the hook? thanks.  
  > **username_0**: and this is what i'm trying to do: http://craftcms.stackexchange.com/questions/9093/linking-to-channel-via-structure-section?rq=1 but i need to link the urls the main structure and its outlying structures/channels, preferably in a dynamic manner  
  > **username_0**: I've changed my mind and decided that urls should not be dynamically set in the site, since I'd prefer to separate system config/data architecture and site output. If we set dynamic urls from the get-go later down the road we will likely regret losing the flexibility of setting urls for each section as whatever is most intuitive/best for SEO, etc. i have not tried your suggestion (nor do i understand it fully) but if anyone else tries it, please comment below to make this question more helpful to others. Thanks for your help.  
  
  ---
  
  