kylewolfe — 2012-11-29T16:33:02-05:00 — #1
To those of you who have at least some sort of MVC framework experience, whether it be ZF or another similar:
I'm going to be re-tackling a CMS for personal use in the next few days. A couple things I've been thinking on and want to get some feedback.
For this I see two possibilities. One option which I have used in the past, is use the error controller to disperse a db request for the desired slug. The second is bootstrap a db request in and create a new route for all pages in the db. I believe I chose the first back in the day considering the overhead. I just don't like the idea of a possibly big request like that before a page even loads, when it may not even b necessary, though I also admit using the error controller seems a little sloppy and unprofessional to me.
As I've been doing some reading, I see there is a feature that I have no experience with yet, and that is Zend Cache. I'm not yet sure how this works, but I wonder if it might be looking into using this or a session to cache the results for my routes somehow? And then perhaps on a 404, do one last check to see if that slug exists in case a new page was recently published since the caching.
The Slug and Parameters
I know I had to of got around this at one point, but I don't remember how... If I use a full URL path as my primary key, (ex. "/articles/some/article/name"), if I add pagination to a certain article, how can I add and retrieve parameters to that url? /articles/some/article/name/page/2 would probably start looking for that slug in the db rather than act as only a parameter being passed.
jeff_mott — 2012-11-29T17:41:17-05:00 — #2
I've typically seen CMSs create an explicit route. It could grab routes from only a specific portion of your site...
...or it can capture everything...
Since routes are checked in order, you could still create routes for non-CMS pages even if it's within the CMS portion of your site...
Of course, any kind of CMS slug lookup like this will always require an initial DB query just to find the page, and leaving the task to the error controller doesn't really alleviate that necessity.
You probably don't need to think about caching the routes explicitly. Rather, you can do normal DB query caching. So the second time /cms/page is requested, your model/persistence layer can return the result without actually querying the DB.
The pagination URLs you want to use, however, do pose a problem. Most likely you'll have to do pagination in the query string.