Hi lightflowmark, thanks for your followup. I appreciate it. =^D
Let me explain my point in more detail so you can get a better picture of
what I'm trying to do. Below is the directory structure of my
module/controllers which I will use to help explain the following details of
the project.
/application
/product
/controllers
ListingController.php
/views
list_products.phtml
/setting
/controllers
SetupController.php
/views
/layouts
setup_layout.phtml
/directory
/controllers
ProductDirectoryController.php
/views
/layouts
directory_layout.phtml
The /product/listing/list/ action uses the list_products.phtml template to
render its contents. Now I have two controllers which forwards control to
the said action: /setting/setup/product and /directory/controller/product.
But the two actions coming from different controller and modules use
different layouts. And what I want to do is instruct the action where I'm
forwarding to (in this case /product/listing/list) to use the layout being
defined in the calling action. That is, if the layout for
/setting/setup/product is setup_layout.phtml, I want /product/listing/list/
to use that layout. Otherwise it will use directory_layout.phtml is
forwarding from /directory/controller/product.
What I mean by now bothering the code of /product/listing/list action is
that I don't want it to know that it's being forwarded from another action.
Like for example adding the getting of parameter layout and setting the
layout from the list action itself as shown below.
class ListingController extends Zend_Controller_Action {
public function listAction() {
$layout = $this->getParam('layout');
if ($layout) {
$this->_helper->layout->setLayout($this->getRequest->getParams($layout));
}
$this->render('list_products.phtml');
}
}
'Coz I don't want the forwarded action to think that it needs to change
layout if a layout parameter is passed to it. What I want to do instead is a
way to tell the forwarded function that it needs to use a specific template
from the calling action. I've made an imaginary interface below to show my
idea of how this can be done. The _forward function returns the
Zend_Controller_Action object of the forwarded action and sets its layout
from the calling function In this case the calling function is productAction
of the Setup controller of the Setting Module.
class SetupController extends Zend_Controller_Action {
public function productAction() {
$forwardedAction = $this->_forward('list', 'listing', 'product');
$forwardedAction->setLayout('setup_layout.phtml');
}
}
Sorry for the long explanation but hope this clears my point. Thanks!
--
View this message in context:
http://www.nabble.com/communicating-with-forwarded-action-tp23173951p23197359.html
Sent from the Zend Framework mailing list archive at Nabble.com.