SitePoint Sponsor |
|
User Tag List
Results 76 to 100 of 101
-
Feb 15, 2005, 06:27 #76
- Join Date
- Feb 2004
- Location
- New York
- Posts
- 474
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is anyone taking into consideration that PHP4 is still used by a majority of web hosts, so posting PHP5 examples might hamper development of good code for people still using PHP4?
In any case, I think this has gotten way too complicated, from my perspective at least. I am simply wondering how I can do the following:
1. User Requests Page
2. Application Begins by accessing Database
3. Determines necesary action based on request (i.e. index.php?cat=apples&page=green)
4. Grabs page data from database
5. grabs template xhtml from database
6. Application puts data in template via variables (i.e. $_PAGE['Title'], $_PAGE['Body'])
7. Sends result to browserIan Gordon
CSS / XHTML / PHP Programmer
http://www.iangordon.us
-
Feb 15, 2005, 06:46 #77
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Ian R. Gordon
This may or may not happen to match your current set of requirements. Judging by the responses you are getting, no one wants to work on a PHP4 only CMS which store it's action mappings and templates in a database. I don't blame them, from the outset that is a set of requirements for a dog slow application.
It seems like you have a very definite perceived need to know something, as you have been posting entries on every MVC thread in the Advanced PHP forum. Every time someone response, you seem give them a terse brush-off, apparently because their response is not served up on the golden platter of your desired requirements.
Perhaps you would be better served by reviewing at the code already posted in these threads with an open mind, and adapting it to your own requirements, rather than asking every forum poster to do that for you.Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
-
Feb 15, 2005, 09:33 #78
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
SweatJe,
Having a lot of respect for yourself, I find it difficult to understand your attitude in what you've posted?
Anyways, to answer some questions
You could create an instance to your database at the top of the page and pass this around although I'd favour using a Singleton so there would be no need to pass the connection around?
A Front Controller can decide how to dispatch an action to a Page Controller for example? A Front Controller could simply be a SWITCH in some cases
For gathering page information this should be a Model (MVC) which is delegated by what logic the Controller has for a given action. In the event you've put a template in the database this is a Model as well, in league with a View to render the template.
Note (in my view) the View shouldn't know the source of the template. You have it in the database for the time being, but you may need to change this to a flat file later, so no, the View has no idea of where the template comes from
Despite SweatJe's attitude, he does have a point however so I would add to what SweatJe has said, and read up on all the MVC threads
-
Feb 15, 2005, 09:43 #79
- Join Date
- Sep 2003
- Location
- Glasgow
- Posts
- 1,690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A template does not become part of the model just because it's stored in a db.
-
Feb 15, 2005, 09:47 #80
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, yer you do have a point there McGruff but what I'm referring to as I see it you do need to fetch the template and for reasons I stated (portability <> reusability) I feel fetching the template it's self belongs in the Model
Are you suggesting that the View fetches the template? I note some people feel that this is justified but I disagree on that point...
-
Feb 15, 2005, 10:14 #81
- Join Date
- Sep 2003
- Location
- Glasgow
- Posts
- 1,690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The template - and any code which applies formatting to page elements - IS the View.
-
Feb 15, 2005, 11:19 #82
- Join Date
- Feb 2004
- Location
- New York
- Posts
- 474
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by sweatje
How I decide to code my application is my business, you don't like templates in a database fine, I do, thats my choice. You don't need to tell me gonna be dog slow.
In anycase, if you didn't want to give me an example or offer me help, you didn't have to make a post and "yell" at me. I am aware of what I did, I was simply seeking solutions.
Originally Posted by Dr Livingston
I am aware of WACT btw.Ian Gordon
CSS / XHTML / PHP Programmer
http://www.iangordon.us
-
Feb 15, 2005, 12:14 #83
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
and any code which applies formatting to page elements - IS the View.
That's my assumption of course and we all have our own idea of MVC so if I'm wrong or something, I'd be interested in knowing more myself now...
-
Feb 16, 2005, 09:39 #84
- Join Date
- Sep 2003
- Location
- Glasgow
- Posts
- 1,690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I can't follow your "reasoning" at all. The model knows nothing about views.
-
Feb 16, 2005, 09:54 #85
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think the central disconnect here is the rule of thumb: all persistant storage (particularly db access) should be done through Model classes.
Of course files are persistant storage as well, so even a Template based View which fetches templates as files is "accessing persistnant storage" without going through a view. I think the twist here is that most of the time the template is not normally in the database, so it spins peoples thinking in different directions.
If the desire is to have the view maintain templates in the database, then the view should have a database connection passed to it and do it's work on it own. As I mentioned earlier, we have already "violated" the rule of thumb by accessing files to begin with, but it is an assumption engrained in our brains as "okay" so we move on without thinking about it until this desired behavior is presented to us in a new aspect (coming out of a db instead of the file system).
Anyway, that is my take on the last few posts.
$0.02
Regards,Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
-
Feb 16, 2005, 10:35 #86
- Join Date
- Sep 2004
- Location
- S. Florida, USA
- Posts
- 60
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by sweatje
-
Feb 16, 2005, 11:33 #87
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by trini0
-
Feb 16, 2005, 14:06 #88
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Umm...
Okay, not wanting to argue with anyone (McGruff) I'll just have to accept that the general consensus on this forum is that it's acceptable for the View in a given context to have a database connection, and just be done with it
Maybe it's because as SweatJe says, not a lot of people use the database for template storage, and it's this approach I've not looked into much?
Consider my view changed now McGruff
-
Feb 16, 2005, 14:46 #89
- Join Date
- Aug 2004
- Location
- California
- Posts
- 1,672
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you sweatje for bringing something important to light.
Let's remember that MVC is a pattern and a goal - NOT a design or a rule. Statements like:The template - and any code which applies formatting to page elements - IS the View.
In the case described here you could implement a method in your Model code that fetched the template data, or you can just fetch the data directly. That most View code loads persistent data related to presentation without using the Model is common practice. This just shows that patterns are guides to practical implementions, not straightjackets for the mind.Christopher
-
Feb 16, 2005, 16:59 #90
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by sweatje
DouglasHello World
-
Feb 16, 2005, 17:30 #91
- Join Date
- Sep 2003
- Location
- Glasgow
- Posts
- 1,690
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I don't know why MVC causes so much confusion (admittedly it used to confuse me too) since it's really very simple.
The important point is the separation of model from presentation. MVC further splits the UI into View and Controller.
Originally Posted by arborint
Originally Posted by arborint
Originally Posted by arborint
Originally Posted by arborint
-
Feb 16, 2005, 17:59 #92
- Join Date
- Oct 2004
- Location
- naperville
- Posts
- 189
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Consider my view changed now McGruff
I'm suprised the fact of file vs database template storage even came up - it shouldnt be an issue; it should (imo) be handled by a template-getter DAO and be decided by like a configuration flag. The method of access should never come up anywhere else. On the same note, I think passing a DB to a view is "ok" although not nescesarily the cleanest method. A singleton would hide this, but hiding is never good.
-
Feb 16, 2005, 18:08 #93
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Off Topic:
Originally Posted by Super Phil
-
Feb 17, 2005, 09:24 #94
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A pun?? Well, I don't know as this wasn't the intention of that statement, I'm actually surprised now that some folks see it that way though
I would like to reply to the recent posts made but I fear I might just start the ball rolling again so I'll keep quiet (for the moment at least)
-
Feb 17, 2005, 09:31 #95
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
SweatJe,
I've just gone and googled the double... as I didn't know what it meant, and I found a jokes site here in the UK
Posted some examples, just for a laugh
Edit:
Inappropriate
Last edited by seanf; Feb 19, 2005 at 07:39.
-
Feb 19, 2005, 03:16 #96
- Join Date
- Mar 2003
- Location
- Sweden
- Posts
- 370
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hello again!
I've been working on thr's example and before I was discussing it with him directly but after the big World of Warcraft influenza that has spread all over the world, I've not seen him online for a while. (I'm not sure this is the case)
Where in his code example (picture, for those who have not checked the code) should I get information from the Model? Should I get it in the ViewController?
Thanks in advance!
Martin Lundberg
Sweden
-
Feb 19, 2005, 04:09 #97
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Er, what information are you talking about? I think this thread went off topic for a while there so excuse me while I got lost (still laughing from my last posting)
-
Feb 19, 2005, 06:47 #98
- Join Date
- Mar 2003
- Location
- Sweden
- Posts
- 370
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hehe, some laughter is allways good in all the confusing posts!
The picture im talking about is at this post: http://www.sitepoint.com/forums/show...5&postcount=70
and the code at this: http://www.sitepoint.com/forums/show...0&postcount=74
and if I understood you wrong and you mean the information that I said I should get from the model. I ment well, information from a database. Let's say I'm going to show a userlist, the UserList action is requested, where in the code is the users actualy taken from the database, that is where should the Model come in? I this code right now, is there a model at all? For mee it feels like alot of controllers and alot of views =)
Martin Lundberg
Sweden
-
Feb 19, 2005, 07:16 #99
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here is an example off the top of my head, and thus its just a simple example
PHP Code:class UserListAction {
...
public function execute() {
$model = new UserListModel; // dumb name btw
$lists = $model -> findById( $_GET['id'] ); // do not use $_GET directly either ;)
...
$view = new PagePrinter( 'templates/basic-template.tpl' ); // the view
$view -> assign( 'list', $lists );
...
}
...
}
This is a basic example though but I hope it gives you some ideas anyways
-
Feb 19, 2005, 09:20 #100
- Join Date
- Mar 2003
- Location
- Sweden
- Posts
- 370
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks! I think I got how I'm supposed to do it, thanks.
Martin Lundberg
Sweden
Bookmarks