magento 模板(主题)制作准备

本文提供了一步一步的指南,从下载安装最新版的magento(包括演示数据),安装中文包,设置后台环境(如关闭缓存和开启debug模式),到创建并测试一个基本模块。详细介绍了如何在后台配置模块、路由、控制器和布局,以及如何通过布局文件和phtml文件展示模块输出。

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

1.下载安装最新版的magento(带演示数据)

2.下一个中文的包(我英文比较差,安装上去,要是想英文的在后台中也是很容易切换的)

3.在后台关闭缓存和开启debug 模式

        a.打开调试模式:直接把index.php 中的

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}

#ini_set('display_errors', 1);


这两条语句变为有效

 

4.写一个用于测试的模块test(主要测试一些关键的输出)

a.新建文件夹  app\code\local\MyTest\Test\Block

app\code\local\MyTest\Test\controllers

app\code\local\MyTest\Test\etc

app\code\local\MyTest\Test\Model

b.新建一个配置文件内app\code\local\MyTest\Test\etc\config.xml容如下

<config>
	<modules>
		<MyTest_Test>
			<version>0.1.0</version>
		</MyTest_Test>
	</modules>
</config>

c.创建一个配置文件app\etc\modules\MyTest_Test.xml内容如下:

<config>
  <modules>
    <MyTest_Test>
      <active>true</active>
      <codePool>local</codePool>
    </MyTest_Test>
  </modules>
</config>


这时候可以在后台system->configuration->advanced 中看到MyTest_Test模块

d.配置路由,编辑上面的config.xml 加上如下代码

<config>
.....
<frontend>
		<routers>
			<mytest>
				<use>standard</use>
				<args>
					<module>MyTest_Test</module>
					<frontName>test</frontName>
				</args>
			</mytest>
		</routers>
	</frontend>
............

e.新建一个控制器文件app\code\local\MyTest\Test\controllers\IndexController.php内容如下

<?php
/*
 * Created on 2014-5-13
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 class MyTest_Test_IndexController extends Mage_Core_Controller_Front_Action {
 	public function indexAction() {
 		echo "test";
 	}
 }
?>

此时访问magento\index.php\test   可以看到页面输出test

f.新建一个布局文件app\design\frontend\base\default\layout\local.xml  内容如下

<layout version="0.1.0">
	<test_index_index>
		<reference name="root">
			<block type="page/html" name="root" output="toHtml" template="test/test.phtml"></block>
		</reference>
	</test_index_index>
</layout>

g.新建一个phtml文件app\design\frontend\base\default\template\test\test.phtml 内容如下

mmmmmmmmmmmmmm
 
h.修改IndexController.php内容如下
<?php
/*
 * Created on 2014-5-13
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 class MyTest_Test_IndexController extends Mage_Core_Controller_Front_Action {
 	public function indexAction() {
 		//echo "test";
 		 $this->loadLayout();  
	     $this->renderLayout();  
 		
 	}
 }
?>

访问此时访问magento\index.php\test   可以看到页面输出mmmmmm到此就可以了,等到以后可以在local.xml加bolck 然后看各个phtml文件的输出



5.下载安装一个layoutview模块

到此准备工作已经完成

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值