6 users online. Create an account or sign in to join them.Users
Nested Pages and URL Params
This is an open discussion with 8 replies, filed under General.
Search
How are people implementing this sort of structure?
How was it implemented in the project you saw? There are many ways to skin this cat.
I’ve done it several different ways, and none of them I’m particularly happy with, so am yet to find the best solution.
Rob’s URL Router extension is dead handy for getting parameters in the middle of URLs. I recently implemented our internal wiki using this:
/clients /clients/:client /clients/:client/wiki/:page /clients/:client/projects /clients/:client/projects/:project /clients/:client/projects/:project/:wiki
“Clients” and “Projects” both have wikis, and you’ll see that the :param sits nested in the URL structure. However it doesn’t solve the “infinite number of children” problem, i.e. it doesn’t do:
/wiki/:page1/:page2/:page-n
I have achieved this in the past by storing the full URL with an entry, for example a text input field with a value of:
/the/url/params/here
And a Data Source “Page URL” which grabs an entry filtering this field. However it requires some .htaccess hackery, and suffers from the obvious problem that if a parent page handle changes, child handles become stale.
Another question on the same subject…
I have a page: /destinations which has 5 levels of URL params after it, being
/destinations/destination/country/region/sub-region/resort
This works well, and I can crawl the tree with my datasources fine. What I need to be able to do now is dynamically append extra params in there too, like:
/destinations/destination:january-deals /destinations/destination/country:march-deals
I’m hoping it’s possible, I just don’t know how. The tree will never go like this
/destination:january-deals/country
It’s just an on-the-fly param for pulling data from another ds at any level it’s at.
Any ideas on how I can achieve this?
You were quick Nick…
Have you got a real life example of how the URL Router/Pages/Data is set up, I’m a little lost as to how it all works together…
Okay, so reading what Nick has said, and realising limitations of what I need, I’ve changed my requirements slightly…
My destinations page now has a subpage of /deals with url params year/month which will be integer rather than string, so I would like to do:
/deatinations/:africa/deals/:2010/:10/ (params preceeded with : )
I can’t understand how to achieve this how Nick mentioned the Wiki and Projects are done:
Rob’s URL Router extension is dead handy for getting parameters in the middle of URLs. I recently implemented our internal wiki using this:
/clients /clients/:client /clients/:client/wiki/:page /clients/:client/projects /clients/:client/projects/:project /clients/:client/projects/:project/:wiki“Clients” and “Projects” both have wikis, and you’ll see that the :param sits nested in the URL structure.
So to begin with build your two Symphony pages without nested params:
/destinations/:country /destination/deals/:country/:year/:month
You’ll then want to install the URL Router field and add some regex on the System Preferences page. Perhaps something like:
From: /\/destinations\/(.+)\/deals\/([0-9]+)\/([0-9]+)/ To: /destinations/deals/$1/$2/$3
My regex isn’t perfect, but features of the above regexp:
- wrap with delimiter
/(as you would in JS or PHP) - since
/is your delimiter, escape forward slashes with a backslash (e.g. to match/destinations/you’d write\/destinations\/
It should match:
/destinations/africa/deals/2010/09/
I always start with the basic URLs (without nested URL Parameters) and add the rewrites at the very end.
(A word of warning: Markdown breaks the regex a bit so if you have to paste any, best use Pastie or Gist!)
You see that’s where I was falling down, I hadn’t sonsidered the destination needing to be at the /deals page..
Brilliant Nick, thank you! (yet again!)
Oh and, just for reference, you don’t need to escape back-slashes (url ones) in Regex, only forward-slashes…
;o)
Sorry, no, you are right…
Create an account or sign in to comment.
I’ve had the opportunity to look at a wonderful peice of Symphony work today that has an interesting page structure. It got me to asking this question.
I’ve always assumed that a page with say, three levels of url params, would not be able to have child pages, yet I can see it can.
How does Symphony know? Is this a ‘best practice’ or a ‘you shouldn’t really do that’?
How are people implementing this sort of structure?