You can have a default "layout", but you could then provide additional methods in the controller for "setLayout()" and even "setLayoutEnabled()" to enable/disable the overall layout. I'm not going to go too far into a discussion on views unless ~scottayy wants us to though since I think it's out of scope and it's another topic againsuperdezign wrote:Then I'll certainly give it a read. ^_^d11wtq wrote:This one does include the view, albeit not a composite one, but it's not hard to modify to work with a composite view.
I just got to the view and was trying to decipher a good method for using the consistent outer template with the inner templates.
many pages, or one page with $_GET parameter
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I updated my code above to add forward via returning a controller/action pair. I don't like to be required to inherit an ActionController class because they usually only provide MVC automation with is often not needed. I prefer to have the option.d11wtq wrote:I did post the ActionController class for a reason, although I should really have had a "Controller" class which but FrontController and ActionController extend. I didn't want to overwhelm thoughSee, now that you've got all responsibility for invoking actions in the front controller it's a little more difficult to control flow between controllers. I guess you have your own clean way of doing that too, but I was going to post this next... I'd be interested in starting a new thread and discussing advtantages and disadvantages in depth because I know you have some great ideas on this sort of stuff. I find it an interesting topic too.
I'm throwing in forwarding here with only a little modification:
Move to a new thread if there is interest in exploring these ideas.
(#10850)
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Nicearborint wrote:I updated my code above to add forward via returning a controller/action pair. I don't like to be required to inherit an ActionController class because they usually only provide MVC automation with is often not needed. I prefer to have the option.
@aborint - Should error handling be processed in a different class? Like an error subcontroller? Or implicitly in each method, as your code seems to imply?
EDIT| @d11wtq, you're like the php thomas edison ;d New ideas flowing all the time. I likes it.
EDIT| @d11wtq, you're like the php thomas edison ;d New ideas flowing all the time. I likes it.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I am not exactly sure what you are asking. I will say that I think the Front Controller should have two defaults: one for when now controller/action is specified and another for when there is an error trying to dispatch. That sort of implies that I am for having the Front Controller forward to an error controller if there is a dispatching error.scottayy wrote:@aborint - Should error handling be processed in a different class? Like an error subcontroller? Or implicitly in each method, as your code seems to imply?
There are a few choices that you need to make with Front Controller default and errors. The main ones are what goes to the default controller and what goes to and error controller. Also what if the class is loaded, but the method is not found, is that an error or should it try the default method name (e.g., run() or indexController()) before erroring.
Once the Action Controller is dispatched then the error handling issues changes and most are application specific. But your idea of a perhaps standard error handler is interesting. Did you have some ideas?
(#10850)
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
That is a very enlightening article d11. I look forward to reading it again and playing with it at work a bit. Thanks for writing that.d11wtq wrote:I took the liberty of writing a short blog entry extending upon the sort of code I posted hereIf it's of any help:
http://www.w3style.co.uk/a-lightweight- ... -for-php-5
- xpgeek
- Forum Contributor
- Posts: 146
- Joined: Mon May 22, 2006 1:45 am
- Location: Kyiv, Ukraine
- Contact:
Sorry for offtop, but with you dispath function i can include any files through you code.d11wtq wrote:skipped...
Now point your browser to:Code: Select all
<?php public function dispatch() { $page = !empty($_GET["page"]) ? $_GET["page"] : "home"; $action = !empty($_GET["action"]) ? $_GET["action"] : "index"; $class = ucfirst($page) . "Controller"; $file = PAGE_DIR . "/" . $class . ".php"; if (!file_exists($file)) { exit("Page not found"); } require_once $file; $page = new $class(); $page->dispatchAction($action); }
http://localhost/index.php?page=survey&action=create
Try something like this:
http://localhost/index.php?page=/../../ ... ion=create
Of course you have to find riht path to passwd file.
Correct me if i mistake.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
"page data" - Are you referring to the controller and function names extracted fome the URL string? Are you suggesting that we store all controller names and function names in a database and verify that the page data is valid?Everah wrote:Ideally you would have the page data being validated against what is known in a database (which could also control your page not found issues).
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia