【问题标题】:How to create new page in magento site如何在magento站点中创建新页面
【发布时间】:2012-07-14 10:43:54
【问题描述】:

我正在尝试在 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。 请说明如何操作。

【问题讨论】:

  • 为什么不用CMS页面呢?
  • 你能告诉我,在哪里添加 html 和 javascript,因为当我将代码粘贴到内容区域时。它会按原样显示而不渲染它。
  • 有一个按钮可以在所见即所得和 HTML 模式之间切换。
  • @ankit:您可以将其添加为自定义块。

标签: php magento e-commerce


【解决方案1】:

插入模块的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 任何内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-07
    • 2018-12-08
    • 1970-01-01
    • 2023-03-31
    • 2011-03-31
    • 1970-01-01
    相关资源
    最近更新 更多