我想我前段时间从客户那里收到了完全相同的要求,这就是我如何管理它,我认为这是最简单和最简单的方法......
实际上,可以直接对模块的 config.xml 文件进行重写。在此示例中,所有 URL 都像
http://www.domain.com/landing/whatever
将被改写为
http://www.domain.com/landingpage/page/view/whatever
配置文件
<?xml version="1.0"?>
<config>
<modules>
<My_LandingPage>
<version>0.0.1</version>
</My_LandingPage>
</modules>
<frontend>
<routers>
<landingpage>
<use>standard</use>
<args>
<module>My_LandingPage</module>
<frontName>landingpage</frontName>
</args>
</landingpage>
</routers>
</frontend>
<global>
<!-- Rewrite requested routes -->
<rewrite>
<my_landingpage_page_view>
<from><![CDATA[#^/landing/#]]></from>
<to>/landingpage/page/view/</to>
<complete>1</complete>
</my_landingpage_page_view>
</rewrite>
</config>
控制器
<?php
class My_LandingPage_PageController extends Mage_Core_Controller_Front_Action {
/**
* View page action
*/
public function viewAction() {
// Get the requested path (/landing/whatever)
$pathInfo = $this->getRequest()->getOriginalPathInfo();
// Extract the requested key (whatever)
$pathArray = explode('/landing/', $pathInfo);
$requestedKey = $pathArray[1];
// So, from there you can use $requestedKey to load any model using it.
// This is also where you will load and render your layout.
}
}
关于布局的旁注
由于调用的真正控制器动作是“landingpage/page/view”,如果您需要此模块的一些布局,它的句柄将是<landingpage_page_view>
.