Page 1 of 1
What is the best way to view...
Posted: Mon Sep 25, 2006 4:19 pm
by psurrena
What would be the best approach for this case:
On the homepage there are two columns - events and news, the titles are pulled from a db. When you click on one or the other it takes you to a new page to view the full content pulled from the db.
I only want one page the view both news and events.
What is the best way for, lets say, view.php to determine the difference between the two db tables (news, events)?
Posted: Mon Sep 25, 2006 4:22 pm
by feyd
The request data?
Posted: Mon Sep 25, 2006 6:46 pm
by Christopher
It sounds like if you had a single "full" view, you could just pass a different model to that view depending on what you wanted to display. The model could provide the page title, and rows of data. Probably you want the model to have getTitles() and getAllContent() methods for use on the home and "full" view pages respectively.
Posted: Mon Sep 25, 2006 8:32 pm
by psurrena
That sounds right - could you elaborate a bit more? Would the model be the "view.php" page? How would you go about distiguishing the two sets of information? Is it through the url (xxx.php?id=2)?
Posted: Mon Sep 25, 2006 10:42 pm
by Christopher
I was thinking that there would be two Models -- NewsModel and EventsModel. They would be polymorphic. You would decide which one to use based on some parameter (like your id=2). This show how web apps often fall into the MVC pattern. You have the Models that provide the data. You have the View that creates HTML with the data in it. And the Controller figures out which Model and View to use base on some parameters.
Posted: Tue Sep 26, 2006 12:49 am
by psurrena
How do people get clean URLs using the method? Instead of
http://www.mysite.com/view.php?id=324 I would get
http://www.mysite.com/view.php/name-of-article/
Or is that a whole other topic?
Thanks for all you help, everything is much more clear now.
Posted: Tue Sep 26, 2006 2:30 am
by Mordred
Posted: Tue Sep 26, 2006 2:16 pm
by Christopher
$_SERVER['PATH_INFO']
psurrena wrote:Or is that a whole other topic?
Yes it is.