Trying to comprehend MVC
Posted: Tue Sep 22, 2009 4:44 pm
Trying to comprehend MVC here.
i've got a part of a site that does 3 things
show search form
show search results
show full record details
I imagine the urls like:
site.com/index.php/realty/search/
site.com/index.php/realty/results/4/ (4 = pagination page number)
site.com/index.php/realty/details/127/ (127 = record id)
I get the basic idea of setting up a _controller_ for that.
1 controller,
a model for pulling the data from mysql,
possibly a separate model/business logic if the search logic is complicated
and 3 methods/actions in the controller to show the 3 "pages",
and 3 templates
But what if one of those 3 actions actually does a few more things?
site.com/index.php/realty/details/127/print/ (show a print-friendly template)
site.com/index.php/realty/details/127/share/ (show a form where the visitor can e-mail a link to his friends)
site.com/index.php/realty/details/127/sharesent/ (show a confirmation page indicating that e-mail was sent)
Do I make another controller just for the 'details' part and somehow put that controller inside the first controller which is already inside of a front-controller?
i've got a part of a site that does 3 things
show search form
show search results
show full record details
I imagine the urls like:
site.com/index.php/realty/search/
site.com/index.php/realty/results/4/ (4 = pagination page number)
site.com/index.php/realty/details/127/ (127 = record id)
I get the basic idea of setting up a _controller_ for that.
1 controller,
a model for pulling the data from mysql,
possibly a separate model/business logic if the search logic is complicated
and 3 methods/actions in the controller to show the 3 "pages",
and 3 templates
But what if one of those 3 actions actually does a few more things?
site.com/index.php/realty/details/127/print/ (show a print-friendly template)
site.com/index.php/realty/details/127/share/ (show a form where the visitor can e-mail a link to his friends)
site.com/index.php/realty/details/127/sharesent/ (show a confirmation page indicating that e-mail was sent)
Do I make another controller just for the 'details' part and somehow put that controller inside the first controller which is already inside of a front-controller?