Wuhtzu Posted April 13, 2008 Share Posted April 13, 2008 Hey I'm about to begin building a small webshop / website to sell and present some t-shirt printing stuff I'm doing, but I'm in doubt about what design pattern I should utilize... More specifically I'm in doubt whether to use the MVC pattern (which I'm fairly new to) or some basic "mix php, mysql and html altogether in script.php" application structure with some includes and stuff. The consists of a minimum of sections: Home -> Home page, offers, news ect. T-shirts -> View our t-shirts Information -> Information about payment, shipment ect. Check out -> Check out and pay for your tshirts Shopping cart -> View the shopping cart What I would like to obtain URL wise: #1 site.com/tshirts -> View all collections #2 site.com/tshirts/military -> View t-shirts in the "Military" collection #3 site.com/tshirts/military/le-tank -> View the t-shirt "Le Tank" within the "Military" collection But I do not see how I can obtain this with the MVC pattern, both well known and homegrown conceptual mvc frameworks all seems to give me something like this: site.com/collections -> View all collections site.com/collections/view/military -> View t-shirts in the "Military" collection site.com/tshirts/view/le-tank -> View the t-shirt "Le Tank" within the "Military" collection I don't particularly like the URL's which I think is inevitable with the MVC pattern and I don't see them in webshops very often. Can I avoid the URLs and still use the mvc pattern? The tempting way to take is, to make a script for each section (home.php, tshirts.php, information.php, shoppingcart.php ect) and do enough rewriting to make it look nice, but on the other hand it will be one large headache when it comes to making consistent page titles, breadcrumb trail, authentication ect... What approach would you suggest I take? I would like to hear any thoughts, ideas or suggestions on how to do this and how not to do this. Best regards Wuhtzu Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted April 13, 2008 Share Posted April 13, 2008 I believe most frameworks allow you to set your own custom routes so you can get the URLs you want. Which framework are you using? If you haven't decided yet I'd recommend Zend Framework. Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted April 13, 2008 Author Share Posted April 13, 2008 I done some work with CakePHP and it took no time to creating a quite astonishing functionality, but to be honest with you I don't like having thousands of functions I don't use. All I need is the basic routing functionality, basic separation of presentation and logic, the url rewriting, some form handling and a structured way of handling page titles. So I'm think about use my own conceptual framework based on articles and tutorials I've red about the net. How will you set up your router to obtain anything other than site.com/module/event/optinal-id-or-something ? (I'm most likely asking a very stupid question here...) Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted April 13, 2008 Share Posted April 13, 2008 You'd have to edit the /app/config/routes.php file. For getting what you'd like I'd guess something like the code below would do. Router::connect('/tshirts', array('controller' => 'collections', 'action' => 'index')); Router::connect('/tshirts/:collection', array('controller' => 'collections', 'action' => 'view')); Router::connect('/tshirts/:collection/:name', array('controller' => 'tshirts', 'action' => 'view')); Also, check out this: http://manual.cakephp.org/chapter/configuration Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted April 13, 2008 Author Share Posted April 13, 2008 Thanks alot. That makes sense. It is basically some form of hard coded rewriting... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.