----- Original Message ----- From: "Matthew Weier O'Phinney" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, November 09, 2006 7:18 PM
Subject: Re: [fw-general] Using multiple controllers

you now have the following URL routes:

   /foo
   /foo/bar
   /bar
   /bar/foo
   /bar/baz

You can also forward to methods in other controllers:

   class FooController extends Zend_Action_Controller
   {
       public function barAction()
       {
           // do some processing
           $this->_forward('bar', 'foo');
       }
   }

What this does is instruct the front controller that it needs to execute
BarController::fooAction() after processing the current action.


Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

I'm ok about this simple exemple, but concretly, in more complex situation, 
there is a probleme;

Imagine you want to construct a back-office and access by this way:  /admin
So if we want administrate a news module, for instance, and construct your url like this: /admin/news/update/id/1/
params currenty are:

array(
'controller'=>admin,
'action' => 'news',
'update'=>'id',
'1'=>null
)

But, in fact, we would like  :

array(
'controller'=>admin,
'action' => 'news',
'id'=>1,
)

To solve this problem, I found this solution in the url : 
/admin/news_update/id/1
Then I use the __call method in AdminController to parse the "controller_action" and forward to to the NewsController as bellow:

class AdminController extends Zend_Action_Controller
{

//...authentifications methods before

 public function __call($m, $a)
{
 $params = $this->_getAllParams();
 if(strpbrk($params['action'], "_")){
  $explode = explode("_" , $params['action']);
  $controller = $explode[0];
  $action = $explode[1];
 } else {
  $controller = $params['action'];
  $action = 'index';
 }
 $this->_forward($controller, $action, $params);
}

}







Reply via email to