2015-05-20 122 views
0

您好,我尝试添加自己的自定义模板磁阻,但我无法做到这一点,我使用以下给出的步骤如下 首先我在应用程序/代码/本地创建一个自己的目录如何在magento中添加自己的自定义模板

- FirstNameSpace 
    - FirstWeb 
     -controllers 
     -IndexController.php 

和IndexController.php作为

<?php 
class FirstNameSpace_FirstWeb_IndexController extends Mage_Core_Controller_Front_Action 
{ 

    public function indexAction() 
    { 
     $this->loadLayout(); 

    } 
    public function testAction() 
    { 
     echo "test action"; 
    } 
} 

代码和磁应用的/ etc /模块/ FirstNameSpace_FirstWeb.xml

代码作为

 <?xml version="1.0"?> 
<config> 
    <modules> 
     <FirstNameSpace_FirstWeb> 
     <active>true</active> 
     <codePool>local</codePool> 
     </FirstNameSpace_FirstWeb> 
    </modules> 
</config> 

而且在应用程序/设计/前端/预设/默认/布局/ firstweb.xml 这样的代码

<layout version="0.1.0"> 
    <firstweb_index_index translate="label"> 
     <label>Contact Us Form</label> 
     <reference name="content"> 
      <block type="core/template" name="contactForm" template="firstweb/form.phtml"/> 
     </reference> 
    </firstweb_index_index> 
</layout> 

,并在像

模板/ firstweb/form.phtml嗨!你好吗 !这是第一个例子

像这样

<?xml version="1.0"?> 
<config> 
    <modules> 
     <FirstNameSpace_FirstWeb> 
      <version>0.1.0</version> <!-- Version number of your module --> 
     </FirstNameSpace_FirstWeb> 
    </modules> 
    <frontend> 
     <routers> 
      <firstweb> 
       <use>standard</use> 
       <args> 
        <module>FirstNameSpace_FirstWeb</module> 
        <frontName>firstweb</frontName> 
       </args> 
      </firstweb> 
     </routers> 
     <!-- This node contains module layout configuration --> 

<layout> 
      <updates> 
       <contact> 
        <file>firstweb.xml</file> 
       </contact> 
      </updates> 
     </layout> 

    </frontend> 
</config> 


Now if i hit the page :http://localhost/magento/index.php/firstweb/index 

config.xml文件我没有得到任何回应

plz帮助我,让我能够在磁加载布局

回答

0

有一些事情是错误的。

设置页面模板:

<layout version="0.1.0"> 
    <firstweb_index_index translate="label"> 
     <label>Contact Us Form</label> 
     <reference name="root"> 
      <action method="setTemplate"><template>page/1column.phtml</template></action> 
     </reference> 

     <reference name="content"> 
      <block type="core/template" name="contactForm" template="firstweb/form.phtml"/> 
     </reference> 
    </firstweb_index_index> 
</layout> 

渲染你的布局:

<?php 
class FirstNameSpace_FirstWeb_IndexController extends Mage_Core_Controller_Front_Action 
{ 

    public function indexAction() 
    { 
     $this->loadLayout(); 
     $this->renderLayout(); 

    } 
    public function testAction() 
    { 
     echo "test action"; 
    } 
} 

而且,你的配置是错误的,应该是firstweb代替接触。联系方式正由核心模块联系人:

  <updates> 
      <firstweb> 
       <file>firstweb.xml</file> 
      </firstweb> 
     </updates> 

试试吧,如果仍然无法正常工作,不断尝试,直到你得到这一切的权利。

+0

它仍然无法正常工作。我正在尝试很多时间。你能否给我提供完整的例子 – kavita

+0

来吧@kavita,“它仍然不工作”根本没有帮助。考虑聘请专业人员为你做这项工作。 – michi

相关问题