Issues

ZF-2535: Regression in ViewRenderer in 1.5 PR

Description

A regression in the ViewRenderer was reported on the fw-general list. The following code:


// from a controller action:
$this->render('layout/admin', null, true);

results in the exception "script 'layout-admin.phtml' not found in path'.

In this particular case, the user has specified a view script in a subdirectory -- and the Inflector is replacing the directory separator with a dash. Directory separators should be preserved.

Comments

Please confirm r8000 fixes this issue.

Inflector altered to include DIRECTORY_SEPARATOR and test added to support such use case.

-ralph

Maybe this issue hangs together with the ZF-2538

Miroslav -- no, ZF-2538 is a very different issue. This particular issue has to do with the specific inflection rules relating to the ':action' target, which did not account for directory separators at all; in the previous released versions, there was no such limitation, which is why this is termed a regression.

I can verify that the fix in trunk resolves the issue.

Sweet sweet, closing issue, Yay.

Yes Raplh, you are right, thank you for your work.

I was looking for a similar issue, in order to know if I should report it or not. It looks like this one, so I will start with a comment here and possibly post the issue later on if it is not allready there. My issue refers to the examples of rendering views from within an action controller while using the MVC. The examples can be found in section 7.7 of the programmers reference guide. I am working in the release version 1.5 of ZF.

Trying these examples from section 7.7 $this->view->render('save'); // does not render /my/save.phtml, instead raises error, scirpt 'save' not found etc. $this->view->render('save.phtml'); //does not render /my/save.phtml, instead raises same error, is looking for 'save.phtml' in scripts directory instead of 'scirpts/my' directory $this->view->render('my/save.phtml'); //does not raise an error, but displays nothing. Echo $this->view->render() etc. does, but I find it strange to echo it inside the controller. I would expect to call echo inside the view.

It is possible that the documented behavior changed over time. Then it is time to update the reference guide to reflect this.

I am not following completely.

Chapter 7.7 of the manual (found here: http://framework.zend.com/manual/en/) is on the Action Helpers.

Specifically, you'd want to be using the viewRenderer action helper. To do that, your examples above (which i cannot seem to find in the manual), would need to be without the direct call to view. $this->render(..) from inside an action controller will proxy to the ViewRenderer.

This is what you should try:


$this->render('save');
$this->render('save.phtml');
$this->render('my/save.phtml');

-ralph