我认为 Zend 脚本设置不正确

发布于 2024-08-22 15:59:02 字数 440 浏览 7 评论 0原文

当我创建一个新的控制器时,即在本例中Authenticate,我还创建了文件夹和文件application/views/scripts/authentication/index.phtml

点击时没有问题url http://dev.local/authentication/ 但是当调用任何操作时,即 http://dev.local/authentication/login,我收到以下错误。

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

无论我要对登录操作进行任何更改,它都不应该自动请求新页面,对吧?还是我错了?

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 problem 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆で 2024-08-29 15:59:02

默认情况下,每个操作都需要其相应的视图(phtml 页面)。如果您想禁用给定操作的视图/布局,您可以使用以下代码:

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

编辑响应评论:

我通常不需要这样做,因为我拥有的操作不需要视图脚本被重定向/转发到其他操作。例如,一旦您的用户通过身份验证(即/authentication/login成功时),您可以将他重定向到主页(或他尝试访问的任何页面)。同样,如果登录失败,我只需在 。

例如,我使用上述代码的唯一操作是通常使用 AJAX 调用并输出一些 JSON 代码的操作

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文