We are developing a CMS. This will have a template system, so for example, if the admin wants to add a news section, then he will have to create a template for that section, and another one for each news, that is, for instance, /news/:int:/:title:/, but that route will be stored at the database... how can I do it?
Asked
Active
Viewed 110 times
1 Answers
1
You could use a common controller as a fallback route so that it catches all routes that the admin might create. This controller then goes on to read the appropriate template and show the data.

Marten
- 1,336
- 10
- 16
-
That is my idea, actually I have already coded that, but I can't figure it out how to save the routes on the database. I can save them also at one json file (I have my confs in such format), but I don't want to be rewriting the file each time a new section/route is added... – Cito Sep 25 '12 at 00:43
-
In my understanding you should not save routes in the database but instead save your sections in a sections table. The controller then checks if an appropriate section exists. It will also handle the int and title parameters and find the correct content. – Marten Sep 25 '12 at 00:51
-
Thats correct, but what if I have n combinations of sections? I mean, not only the ones with the type: /section/id/title, but some with /id/, others with just the /title/... by saving the routes in the db (or in other place) the system will be as flexible as the zend_route is, but without the knowledge of the language (in this case, PHP) – Cito Sep 25 '12 at 00:59
-
I'm sorry, I think I would need to be more involved in your project to give you a good answer. – Marten Sep 25 '12 at 01:42
-
Thanks @CQQL. I think here http://stackoverflow.com/questions/3998202/how-to-create-a-custom-router-in-zend-framework#answer-4007797 I have find a clue about how to do it. I need exactly the same idea but instead of only save in the database the category, I need to save the full Zend_Route object. I'll post my solution tomorrow, as soon as I have finished it. Thanks again for your help. – Cito Sep 25 '12 at 07:13