> 2) trying to locate a resource depends on what your data model is > like. You essentially need a central repository that acts as your site > map which consists of parent_ids and stubs/slugs for that resource. > Assuming resource stubs/slugs are unique, it'd be a simple matter of > retrieving from the database based on the last part of the URL. If > they're not unique then you need to check each part of the URL and > match it against a node in the tree. A little more "expensive". You > could denormalize your database to solve this problem by storing full > path names in an additional field and update it if an article is ever > moved or renamed.
I don't know why I never thought of this -- the database that I inherited, and that I plan to keep, is pretty well structured and nicely normalized, but because the "pages" table just has fields for the URI "portion" and the parent ID, it does lead to lots of expensive recursion. Adding a field for the full path is a great idea, although it would be risky in that I can see quite a few scenarios where the path could get "stale". I would have to take great care in building the CMS such that any operation that could change a path rebuilds all the paths after any update. The upside is much quicker and easier lookups on the frontend. > 4) in Cake, in order to be able to take the URL and map it out. You > could try URL rewriting and take /part/part/part/ and convert it into > /part-part-part/ (or some other delimiter that's Cake-friendly). > Otherwise, you'll probably have to hack up the dispatcher to do what > you want. I think this along with what James K suggested above is the way to go -- rewrite all urls to /pages/part1-part2-part3 (or /pages/part1-part2- part3/param:value if there are page params), and in my custom pages controller load the page in question, look for a custom page template and set it if found, look for a custom controller/action and call it if found. Better to do the right thing in a custom pages controller I think than try to rewrite the dispatcher and routes.php. Thanks for all the advice, guys. Matthew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
