开发者

zend framework routing and layout

I have a CMS base controller that most of my other controllers extend. It has a default action for list, create, read, update and delete actions, all of them set the title based on the name of the resource(s) the user is working w开发者_如何学Pythonith.

The index action defaults to contain only one row:

$this->_forward('list');

Now my problem is that my previously set title is gone when I open the index of a CMS controller. I'd like to know what could be happening and what is the best solution of this.

Note that the problem does not appear if I rename my list action to index. It may also be relevant that changing the view title in the index action does not work.


Hmm, where do you set your title and in what way do you do it? Personally my titles are only two parts like "Application: current action". To achieve this i do the following:

//layout.phtml
<?=$this->headTitle()->setPrefix('APP: ')?>

//indexAction()
$this->_forward('list');

//listAction()
$this->view->headTitle()->append('List Data');

I do this for every action separately and since i do not assign a title within indexAction() i get the full wanted title "APP: List Data" inside listAction(). This remains true if i have my edit action like the following

//editAction()
if (!is_numeric($this->_getParam('id'))) {
  return $this->_forward('list');
}

If this doesn't do it for you, your scripts will be needed to look for an error elsewhere :)


Actually, my initial idea of this issue having to do something with routing was right. I'm loading the layout in a preDispatch action of an action controller. So what actually happend was that I re-created my layout view after setting the title attribute in the index action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜