简体   繁体   English

Phalcon标签可在/index/index.phtml上使用,但不能在/signup/index.phtml上使用

[英]Phalcon Tag working at /index/index.phtml but not at /signup/index.phtml

I'm following the tutorial at Phalcon's page ( https://docs.phalconphp.com/en/3.4/tutorial-base ) and I got stuck at creating the /view/signup/index.phtml. 我正在遵循Phalcon页面( https://docs.phalconphp.com/en/3.4/tutorial-base )上的教程,并且无法创建/view/signup/index.phtml。

When I access the /signup/index.phtml page it only shows me the HTML tags, that is, "Sign up using this form". 当我访问/signup/index.phtml页面时,它仅显示HTML标记,即“使用此表单注册”。 None of the $this->tag show. 没有$this->tag显示。 I copied the linkTo tag from the /views/index/index.phtml to the signup view but it didn't work as well, even though it's working perfectly in the index/index.phtml. 我将linkTo标记从/views/index/index.phtml复制到了注册视图,但是即使在index / index.phtml中运行正常,它也无法正常工作。 Somehow no Tag is working at the /signup view. 在/ signup视图中,某种方式没有标签起作用。

Does anyone know why? 有人知道为什么吗?

The codes 密码

/app/controllers/SignupController.php /app/controllers/SignupController.php

<?php

use Phalcon\Mvc\Controller;

class SignupController extends Controller
{
    public function indexAction()
       {

       }
}

/app/views/signup/index.phtml /app/views/signup/index.phtml

<h2>Sign up using this form</h2>

<?php echo $this->tag->form("signup/register"); ?>

<p>
    <label for="name">Name</label>
    <?php echo $this->tag->textField("name"); ?>
</p>

<p>
    <label for="email">E-Mail</label>
    <?php echo $this->tag->textField("email"); ?>
</p>

<p>
    <?php echo $this->tag->submitButton("Register"); ?>
</p>

Check your URL 检查您的网址

Are you using /signup/index.phtml in your browsers address bar? 您是否在浏览器地址栏中使用/signup/index.phtml

You should have something like localhost/tutorial/signup 您应该有类似localhost/tutorial/signup

You will be able to visually see templates by going to their path directly, but the php will not run. 您将可以通过直接转到模板的路径直观地查看模板,但是php无法运行。

Not all resources being included 并非所有资源都包括在内

If you are using the URL paths seen in the tutorial, check that all resources are being loaded into the SignupController correctly by doing the following: 如果您使用的是本教程中看到的URL路径,请执行以下操作,检查所有资源是否已正确加载到SignupController中:

var_dump($this->tag)

This should display something in regards to "form" or a whole bunch of text. 这应该显示有关“形式”或一堆完整文本的信息。 If you see nothing the `Phalcon\\Tag' class is not loading in correctly. 如果看不到任何内容,则说明“ Phalcon \\ Tag”类未正确加载。

You probably may even have a typo somewhere. 您甚至可能在某个地方有错字。 I would recommend copying and pasting the tutorial instead of typing, only while bug checking, to make sure there are no typos. 我建议仅在错误检查时复制和粘贴本教程,而不是键入内容,以确保没有错别字。 You can use a tool like a diff checker to compare your files to their tutorial. 您可以使用差异检查器之类的工具将文件与其教程进行比较。

Online diff checker : https://www.diffchecker.com/ 在线差异检查器: https : //www.diffchecker.com/

Views are not supposed to be accessed directly. 不应直接访问视图。 Try to use Phalcon Developer Tools to set up your app skeleton or use the simple MVC example . 尝试使用Phalcon Developer Tools设置应用程序框架或使用简单的 MVC示例 Notice that you must have mod_rewrite enabled (if you are working in Apache). 请注意,您必须启用mod_rewrite (如果您在Apache中工作)。 Then continue following the tutorial (create the Loader , DI with view , etc) and you will be surprised by the magic of Phalcon. 然后继续按照本教程进行操作(创建Loader ,具有view DI等),您将对Phalcon的神奇之处感到惊讶。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM