开发者

Zend scripts not setup correctly I think

When Ive created a new controller, ie in this case Authenticate, Ive also created the folder and file application/views/scripts/authentication/index.phtml

Not a proble开发者_运维问答m when hitting the url http://dev.local/authentication/ but when calling any action ie http://dev.local/authentication/login, I get the error below.

Message: script 'authentication/login.phtml' not found in path (C:\Sites\application\views\scripts\)

Regardless of any changes Im going to make to the login action it shouldnt automatically ask for a new page right? or am I wrong?


By default, each action requires its corresponding view (phtml page). If you want to disable a view/layout for a given action, you can use the following code :

$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

EDIT in response to the comment:

I usually don't need to do this, because the actions I have that don't need a view script are redirected/forwared to other actions. For example, once your user is authenticated (i.e. when /authentication/login succeeds), you can redirect him to the home page (or whatever page he was trying to access. Similarly, if the login failed, I simply set an error message in the view and forward to the action that shows the login form.

The only actions for which I use the above code is for actions that are typically called using AJAX and that output some JSON code, for example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜