如何在magento网站创建新页面


How to create new page in magento site

我正试图在magento中创建一个新页面,其中我必须添加一些html和javascript。为此,我创建了一个模块。->app''code''local''CompanyName''HelloWorld''etc''config.xml的内容-

 <?xml version="1.0"?>
 <config>
<modules>
    <CompanyName_Helloworld>
        <version>
            0.1.0
        </version>
    </CompanyName_Helloworld>
</modules>
<frontend>
    <routers>
        <helloworld>
            <use>standard</use>
            <args>
                <module>CompanyName_Helloworld</module>
                <frontName>Helloworld</frontName>
            </args>
        </helloworld>
    </routers>
</frontend>

->app''code''local''CompanyName''HelloWorld''controllers''IndexController.php的内容-

<?php
 class CompanyName_Helloworld_IndexController extends   Mage_Core_Controller_Front_Action{
public function indexAction(){
    $this->loadLayout();
           $this->renderLayout();
    //echo "We're echoing just to show that this is what's called, normally you'd have some kind of redirect going on here";
  }
 }

?>

完成所有这些之后,当我转到domain/index.php/Helloworld时我可以看到页眉和页脚,现在我想在它们之间添加一些"div"标记和javascript。请解释如何操作。

插入模块的config.xml:

<frontend>
...
  <layout>
    <updates>
      <helloworld>
        <file>helloworld.xml</file>
      </helloworld>
    </updates>
  </layout>
</frontend>

下一步添加布局文件app/design/frontend/default/default/layout/helloworld.xml:

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
  <helloworld_index_index>
    <reference name="content">
      <block type="helloworld/index" name="helloworld_any_block" template="helloworld/index.phtml" />
    </reference>
  </helloworld_index_index>
</layout>

最终添加带有任何内容的phtml文件app/design/frontend/default/default/template/helloworld/index.phtml