From: Richard L. <ce...@l-...> - 2006-11-14 18:01:57
|
On Thu, November 9, 2006 8:26 am, Nola Stowe wrote: > I also have done some rails and it inspired my "Stupidly Easy MVC > Framework" (links here: http://devasap.net/programming.html) ... and > in recent weeks I have been looking more closely at Zend > Framework.Which in itself, is more like PEAR than Rails, but looks > like it has a nifty MVC Front Controller that works pretty well I > think. I tried to do an MVC thingie (not knowing it was called MVC) back in PHP3 days... And it just ended up having so much cruft in the Controller file, that I abandoned it and never went back. I don't really feel the need for a single Controller when I can centrally locate the authentication in one include file, the db connection in another, and pull those both in (or not, sometimes, when appropriate) through a 'globals.inc' file that handles the masthead and footer and site-wide layout / navigation. Or maybe that *is* my Controller, just done with PHP includes. LOL. One issue is that it's a lot easier to tell somebody to go to the "foo.htm" page (which is PHP, of course) than to go to "index.php?page=foo" Now, of course, you can do all kinds of URL-rewriting tricks in PHP or (shudder) mod_rewrite in Apache, but I find it easier to just have a foo.htm page with: <?php require 'globals.inc'; head("Page Title"); //masthead, navigation, basic layout "shell" //page-specific business logic ?> Page specific content and presentation logic <?php foot(); //closing tags for head() ?> The one-page logic rarely exceeds a screenful, and the HTML layout might be 2 screens with all the tags and all that, but that's hardly difficult The nice thing about PHP/Ruby/Python and all that is you have a lot of options, and can use whatever you like best. The head() and foot() functions are before/after each other in the globals.inc file, so the "shell" of the layout reads just like an HTML page. The head() function might also take an extra arg for business-logic specific purposes, such as a flag to suppress the "usual" layout for the homepage or perhaps a custom stylesheet to insert into the HEAD tags for just this one page. The head() function may also key off of $_SERVER['PHP_SELF'] which has foo.htm to put in a link to 'foo.css' if it exists, or perhaps a foo.png image in the masthead to help them know where they are or something like that. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |