2010-07-16 117 views
0

我創建了該文件,甚至將代碼添加到了items_controller文件(我之前學習過,因爲不需要在普通PHP中執行此操作),但仍然收到一條消息,指出找不到新頁面。在CakePHP中創建新頁面

http://neighborrow.com/items/create/

誤差必須在items_controller文件,因爲它的工作在調試模式,但是當我列出一個項目它顯示我從項目複製的確認消息/即使我編輯它創建添加頁面:

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)); 
        } 
       } 
      } 
     } 
    } 
+0

嘗試設置Configure :: write('debug',1);在config/core.php中,你可以看到來自CakePHP的錯誤消息。 – Oscar 2010-07-16 17:24:48

+0

http://neighborrow.com/items/create/排序工作:)沒有告訴我爲什麼,只是顯示頁面現在...所以如果我刪除調試設置它會再次顯示錯誤? – adam 2010-07-16 17:33:33

+0

老實說,你不知道你做了什麼或正在嘗試做什麼......似乎在你的網站上有所有類型的錯誤.. – Oscar 2010-07-16 17:45:55

回答

3

創建一個新的頁面後,您需要設置調試到> 0,因爲否則將不能再生緩存,緩存文件將不會有新的動作。您也可以手動刪除緩存(刪除app/tmp/cache下的文件,關閉我的頭頂部)。將其設置爲'1'不會執行大多數調試工作,但會重新生成模型文件。因此,當您設置調試來查看它時,它會重新生成緩存文件並運行。

新規則:當您創建新的動作或模型時,請將debug設置爲1或在嘗試對其執行任何操作之前清除緩存。

+0

ver有趣 - 不知道...我仍然從添加頁面獲取反饋消息而不是創建頁面所以我認爲我的控制器文件中有些東西仍然是錯誤的 – adam 2010-07-17 16:01:49

+0

您收到/尋找什麼反饋信息?如果只打開一次調試應該重新生成緩存,頁面關閉後仍然應該顯示。 – cincodenada 2010-07-19 22:03:51