在CakePHP中创建新页面

在CakePHP中创建新页面,cakephp,Cakephp,我创建了这个文件,甚至将代码添加到items_controller文件中(这是因为我不必在普通的PHP中这样做),但仍然收到一条消息,表明找不到新页面 错误必须出现在items\u controller文件中,因为它正在调试模式下工作,但当我列出一个项目时,它会显示我从items/add页面复制的确认消息,即使我将其编辑为create: function create() { if(!empty($this->data)) {

我创建了这个文件,甚至将代码添加到items_controller文件中(这是因为我不必在普通的PHP中这样做),但仍然收到一条消息,表明找不到新页面

错误必须出现在
items\u controller
文件中,因为它正在调试模式下工作,但当我列出一个项目时,它会显示我从items/add页面复制的确认消息,即使我将其编辑为create:

    function create()
    {
        if(!empty($this->data))
        {
            if (!empty($this->data))
            {
                $user_error = false;
                $this->Item->create();
                if($this->Auth->user())
                {
                    $user_id = $this->Auth->User('id');
                }
                else
                {
                    if (!$user_id = $this->Item->User->is_user($this->data['Item']['user_email']))
                    {
                        $email = $this->data['Item']['user_email'];

                        // Create Password
                        $raw_password = $this->PasswordHelper->generatePassword();

                        // Has Password
                        $hashed_password = $this->Auth->password($raw_password);

                        // Add User
                        if (!$user_id = $this->Item->User->add_basic($email, $hashed_password))
                            $user_error = true;

                        // Login the User
                        $this->Auth->login(array('email' => $email, 'password' => $hashed_password));

                        // Send Registration Email
                        $this->Email->send_registration_email($email, $raw_password);
                    }
                }
                if(!$user_error)
                {
                    $this->data['Item']['user_id'] = $user_id;
                    $this->data['Item']['approved'] = 1;
                    if ($this->Item->save($this->data))
                    {
                        $this->Session->setFlash('Congratulations on your first listing! After we review it to make sure it is rentable, we will send you your free profile where you can list, promote, and rent up to nine more items.   Feel free to share you new listing right away! <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>.');
                        $this->redirect(array('controller' => 'items', 'action' => 'view', $this->Item->id));
                    }
                }
            }
        }
    }
函数创建()
{
如果(!empty($this->data))
{
如果(!empty($this->data))
{
$user\u error=false;
$this->Item->create();
如果($this->Auth->user())
{
$user_id=$this->Auth->user('id');
}
其他的
{
如果(!$user\u id=$this->Item->user->is\u user($this->data['Item']['user\u email']))
{
$email=$this->data['Item']['user_email'];
//创建密码
$raw_password=$this->PasswordHelper->generatePassword();
//有密码
$hashed\u password=$this->Auth->password($raw\u password);
//添加用户
如果(!$user\u id=$this->Item->user->add\u basic($email,$hash\u密码))
$user\u error=true;
//登录用户
$this->Auth->login(数组('email'=>$email,'password'=>$hash_password));
//发送注册电子邮件
$this->Email->send\u registration\u Email($Email,$raw\u password);
}
}
如果(!$user\u错误)
{
$this->data['Item']['user\u id']=$user\u id;
$this->data['Item']['approved']=1;
如果($this->Item->save($this->data))
{
$this->Session->setFlash('祝贺您第一次登录!在我们检查它以确保它是可出租的之后,我们将向您发送您的免费个人资料,您可以在其中登录、推广和租赁多达九个项目。请随时与您共享新登录的物品!');
$this->redirect(数组('controller'=>'items','action'=>'view',$this->Item->id));
}
}
}
}
}

创建新页面后,您需要将debug设置为>0,因为否则它不会重新生成缓存,缓存文件也不会有新操作。您也可以手动删除缓存(删除app/tmp/cache下的文件,从我的头顶删除)。将其设置为“1”不会执行大多数调试工作,但会重新生成模型文件。因此,当您设置debug查看它时,它会重新生成缓存文件并工作


因此,新规则:当您创建新操作或模型时,请将“调试”设置为1或在尝试对其执行任何操作之前清除缓存。

创建新页面后,您需要将“调试”设置为>0,因为否则它将不会重新生成缓存,并且缓存文件将不会有新操作。您也可以手动删除缓存(删除app/tmp/cache下的文件,从我的头顶删除)。将其设置为“1”不会执行大多数调试工作,但会重新生成模型文件。因此,当您设置debug查看它时,它会重新生成缓存文件并工作


因此,新规则:当您创建新操作或模型时,请将“调试”设置为1或清除缓存,然后再尝试对其执行任何操作。

尝试设置Configure::write(“调试”,1);在config/core.php中,您可以看到来自CakePHP的错误消息。那种工作:)没有告诉我为什么,只是现在显示页面。。。因此,如果我删除调试设置,它将再次显示错误,对吗?老实说,我不知道你做了什么或正在尝试做什么。。你的网站上似乎有各种各样的错误..我想做的就是在调试关闭时显示该页面。。。除了用户评级之外,您还看到了哪些其他错误?嗯,请尝试提交表单供初学者使用。。然后尝试转到主页。尝试设置Configure::write('debug',1);在config/core.php中,您可以看到来自CakePHP的错误消息。那种工作:)没有告诉我为什么,只是现在显示页面。。。因此,如果我删除调试设置,它将再次显示错误,对吗?老实说,我不知道你做了什么或正在尝试做什么。。你的网站上似乎有各种各样的错误..我想做的就是在调试关闭时显示该页面。。。除了用户评级之外,您还看到了哪些其他错误?嗯,请尝试提交表单供初学者使用。。试着去你的主页..很有趣-不知道。。。我仍然从添加页面而不是创建页面收到反馈信息,因此我认为我的控制器文件中仍然存在问题。您收到/寻找的反馈信息是什么?只需打开一次调试就会重新生成缓存,关闭后页面仍会显示。非常有趣-不知道。。。我仍然从添加页面而不是创建页面收到反馈信息,因此我认为我的控制器文件中仍然存在问题。您收到/寻找的反馈信息是什么?只要打开调试一次,就会重新生成缓存,关闭后页面仍会显示。