You should redirect the the request to one of your controller actions. From there you can use the default Magento layout/block system to present the data you want the customer to see.
Here is what worked for me.
app/etc/modules/Easylife_Brand.xml - declaration file
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Brand>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Core />
</depends>
</Easylife_Brand>
</modules>
</config>
app/code/local/Easylife/Brand/etc/config.xml - configuration file
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Brand>
<version>0.0.1</version>
</Easylife_Brand>
</modules>
<frontend>
<routers>
<brand>
<use>standard</use>
<args>
<module>Easylife_Brand</module>
<frontName>brand</frontName>
</args>
</brand>
</routers>
<layout>
<updates>
<easylife_brand>
<file>easylife_brand.xml</file>
</easylife_brand>
</updates>
</layout>
</frontend>
<global>
<events>
<controller_front_init_routers>
<observers>
<brand>
<class>Easylife_Brand_Controller_Router</class>
<method>initControllerRouters</method>
</brand>
</observers>
</controller_front_init_routers>
</events>
</global>
</config>
app/code/local/Easylife/Brand/Controller/Router.php - custom router.
<?php
class Easylife_Brand_Controller_Router extends Mage_Core_Controller_Varien_Router_Abstract{
public function initControllerRouters($observer){
$front = $observer->getEvent()->getFront();
$front->addRouter('brand', $this);
return $this;
}
public function match(Zend_Controller_Request_Http $request){
if (!Mage::isInstalled()) {
Mage::app()->getFrontController()->getResponse()
->setRedirect(Mage::getUrl('install'))
->sendResponse();
exit;
}
$pathInfo = trim($request->getPathInfo(), '/');
$params = explode('/', $pathInfo);
if(isset($params[0]) && $params[0] == 'brands') {
//redirect to mymodule/brands/index/brand_name/addidas
$request->setModuleName('brand')
->setControllerName('index')
->setActionName('index');
if (isset($params[1])){
$request->setParam('brand_name', $params[1]);
}
$request->setAlias(
Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS,
$pathInfo
);
return true;
}
return false;
}
}
app/code/local/Easylife/Brand/controllers/IndexController.php - the controller
<?php
class Easylife_Brand_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction(){
$brandName = $this->getRequest()->getParam('brand_name', null);
$this->loadLayout();
$block = $this->getLayout()->getBlock('brands');//get the block instance
if ($block){ //if block is valid
if (is_null($brandName)){//if no brand name is supplied
$block->setTemplate('easylife_brand/no_brand.phtml');
}
else{
$block->setTemplate('easylife_brand/adidas.phtml');
}
}
$this->renderLayout();
}
}
app/design/frontend/base/default/layout/easylife_brand.xml - layout file
<?xml version="1.0"?>
<layout>
<brand_index_index>
<reference name="content">
<block type="core/template" name="brands" as="brands" />
</reference>
</brand_index_index>
</layout>
app/design/frontend/base/default/template/easylife_brand/no_brand.html - demo template shown when no brand parameter is passes.
<div>
No brand selected:<br /><br />
List of brands:<br />
Adidas<br />
Nike<br />
</div>
app/design/frontend/base/default/template/easylife_brand/adidas.html - demo template shown when a brand parameter is passes.
<div>This is the adidas brand page.</div>
Clear the cache.
Now when I call mysite.com/brands/
I get the first template (the one with 'No brand selected'.
If I call mysite.com/brands/addidas
or mysite.com/brands/something
I get the second template. ('this is the adidas brand page').