如何在magento站点中创建新页面

ank*_*kit 3 php magento e-commerce

我正在尝试在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>
Run Code Online (Sandbox Code Playgroud)

内容 - > 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";
  }
 }
Run Code Online (Sandbox Code Playgroud)

?>

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

小智 9

插入模块config.xml:

<frontend>
...
  <layout>
    <updates>
      <helloworld>
        <file>helloworld.xml</file>
      </helloworld>
    </updates>
  </layout>
</frontend>
Run Code Online (Sandbox Code Playgroud)

接下来添加布局文件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>
Run Code Online (Sandbox Code Playgroud)

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