开发者

MVC structure for displaying content

开发者 https://www.devze.com 2023-03-30 10:30 出处:网络
If you at this website: http://www.illyriad.co.uk/Codex it is powered by ASP.NET MVC Now I presume that Codex is a Controller, but within the codex they have Factions, Magic and a Bestiary. Choosing

If you at this website: http://www.illyriad.co.uk/Codex it is powered by ASP.NET MVC

Now I presume that Codex is a Controller, but within the codex they have Factions, Magic and a Bestiary. Choosing a random faction such as http://www.illyriad.co.uk/Codex/Faction/73 it seems as though Faction is a method and the 73 being the ID or do you think that they are still using a details method and then Faction is a category?

The reason I ask is that I am planning on building s开发者_如何学JAVAomething similar soon using CakePHP and I'm wondering if it's easier to just create a method to show the different stuff or just a details method and then change the URL using Routing.

Any suggestions etc would be much appreciated. Thanks


MVC does not mean the first parameter from the root is the controller, the second is the action, etc. MVC is a software architecture, while URL structure can only be considered part of the view that shows the webpage hierarchy.

The structure /:controller/:action/:parameter1... is a convention used in several web frameworks (RoR, CakePHP, CodeIgniter, etc.) It's not a rule that anyone has to follow. And with routing in cake, you can completely alter the url structure to your liking (although it could be pretty complicated).

So to answer your question: Codex doesn't have to be controller, Faction doesn't have to be action. I'll write an example routing rules here if you want to do similar thing in Cake:

Router::connect('/Codex/', array('controller' => 'codexs', 'action' => 'index'));
Router::connect('/Codex/Faction/*', array('controller' => 'factions', 'action' => 'view'));
0

精彩评论

暂无评论...
验证码 换一张
取 消