0

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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

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...
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.
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)
I'm sorry, I think I would need to be more involved in your project to give you a good answer.
Thanks @CQQL. I think here stackoverflow.com/questions/3998202/… 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.