简体   繁体   中英

How to implement dynamic content types in CakePHP

I have built up a database structure that works with entities as general pieces of content for the site. This includes pages, articles and the different content types one could imagine.

Now foreach type of entity i want to have a different url, like "/page/xy" or "/article/xy", without having to setup a page controller or an article controller.

So my question in short is: How to implement dynamic content types? I can not write an mvc-bundle foreach url, because I don't know beforehand which types might come!

My approach in raw PHP would be to create an index.php file that reads out the current url and searches in the database for an entity type with the given name of the first segment in the url. if there is an entity type with that name, it shall print a list with entities that are of that type. Pretty easy in raw PHP, but how to do it in CakePHP?

Implement a controller say site that will be able to handle all the objects with the parameters for example:

site/page/xy
site/article/xy
site/post/xy
site/user/xy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM