为我们的Hello World模块创建一个简单的HTML模板(magento)

本文详细介绍了如何为HelloWorld模块创建一个简单的HTML模板,包括布局配置、页面样式和基本内容展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

为我们的Hello World模块创建一个简单的HTML模板。首先我们要创建如下文件

app/design/frontend/default/default/layout/local.xml

包含以下内容

<?xml version="1.0" encoding="UTF-8"?>

<layout version="0.1.0">

    <helloworld_index_index>

        <reference name="root">

            <block type="page/html" name="root" output="toHtml" template="helloworld/simple_page.phtml"/>

        </reference>

    </helloworld_index_index>

</layout>

再创建如下文件

app/design/frontend/default/default/template/helloworld/simple_page.phtml

包含以下内容

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>Untitled</title>

    <style type="text/css">

        body {

            background-color:#f00;

        }

    </style>

</head>

<body>

<h4>Links</h4>

<?php echo $this->getChildHtml('top.links'); ?>

<?php echo $this->getChildHtml('customer_form_register'); ?>

</body>

</html>

最后,我们要在执行控制器里面调用布局文件,开始输出HTML。修改执行方法如下

public function indexAction() {

    //remove our previous echo

    //echo 'Hello Index!';

    $this->loadLayout();

    $this->renderLayout();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值