What I am trying to create here is a lookup mechanism that if the controller/action combination does not exist, to look up the original URI against a known table and serve the request from that or have the error controller display the appropriate page as usual.
I can use the router() function from within the errors controller (which serves the final 404 error page), but the only information I get is for the current request and not the request that originated the 404? I can override if I at least have a controller but no action that matches, but that won't always be the case, and creating dummy controllers for every possible combination is a bit extreme. Is this even possible?
Our CMS works like that, it doesn't have a single controller/action except for a generic loader that ":any" is routed to.
Our pages are in a tree table accessed by ORM's NestedSet model, and we use the result of Uri::segments() to search the tree for the required page definition.
Again, thank you very much for the help, I was not having much fun having to figure this out! And the tip about NestedSet is appreciated, I'll take a good look into it!
Say your URI is "/this/that", then Uri::segments() will return an array with the individual segments in the URI.
Then fetch the root of your NestedSet tree as start page, and loop over the segments. i.e. check if the start page has a child named "this". If so, set that child as page, and loop. If not, then "/this" is the page requested, and "that" is a parameter to that page.
This is how our system does it.
Using ORM you can then relate the rest of the page to the components of that page: theme info, templates, widgets, etc. We then loop over that info, use HMVC requets to fetch the widgets, and the Theme class to compose and generate the page.
I have a _root_, a _404_, and a :any route. The :any route points to common/route which does the magic, but I've hit a wall when trying to do HMVC requests, they get routed back to common/route. I don't know if I've done everything right, but I don't know exactly what else to try at this point.