douqi3195 2016-03-21 07:31
浏览 25
已采纳

无法加载布局或未检测到的phtml

well, i don't now what is the problem is. but it seem like i cannot load layout or phtml. this is my code

config.xml

 <modules>
    <Email_Rent><!-- code/local/Email/Rent-->
      <version>1.0.0</version>
    </Email_Rent>
 </modules>
 <global>
     <!-- Declare block class -->
     <blocks>
         <rent><!-- route -->
              <class>Email_Rent_Block</class>
         </rent>
      </blocks>

</global>

 <frontend>
   <routers>
      <rent>
          <use>standard</use>
          <args>
             <module>Email_Rent</module>
             <frontName>rent</frontName>
          </args>
       </rent>
   </routers>
   <!-- declare layout for block -->
   <layout>
       <updates>
            <rent><!-- route -->
                 <file>rent.xml</file>
             </rent>
        </updates>
    </layout>
</frontend>

this is rent.xml

<layout version="0.1.0">
<rent_index_index>
    <reference name="content">
        <block type="rent/indexblock"  name="form_rent_block" template="rent/rent_form.phtml" />
    </reference>
</rent_index_index>

i already put var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles());

in my index controller. and it print out "rent_index_index"

indexcontroller.php

class Email_Rent_IndexController extends Mage_Core_Controller_Front_Action
{
    public function IndexAction() {

        $this->loadLayout();
        $this->renderLayout();
        //echo 'test index';
    }
    public function saveAction()
    {
        //getrequest->getpost is same as $_request/$_get/$_post function
        // get data from afficher.phtml same as View  
        $name = ''.$this->getRequest()->getPost('name'); //textfield nom
        $email = ''.$this->getRequest()->getPost('email'); //textfield prenom
        $telephone = ''.$this->getRequest()->getPost('telephone'); //textfield telephone
        //if all textfield is been filled
        if(isset($name)&&($name!='') && isset($email)&&($email!='') && isset($telephone)&&($telephone!='') )
        {
            //save data / insert sql
            $contact = Mage::getModel('test/test');
            $contact->setData('name', $name);
            $contact->setData('email', $email);
            $contact->setData('telephone', $telephone);
            $contact->save();
        }
        //on redirige l’utilisateur vers la méthode index du controller indexController
        //de notre module <strong>test</strong>
        $this->_redirect('index.php/test');
    }
}
  • 写回答

1条回答 默认 最新

  • dongzhunqiu4841 2016-03-21 07:45
    关注

    Did you add this in your controller action

     $this->loadLayout();  
     $this->renderLayout(); 
    

    This code should be inside your index controller.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路