1

I tried creating a non CMS page in Magento 1.9. I followed these steps :

Created a folder called 'Returns' in app/code/local and within it created another sub folder called 'Returns' with 2 folders 'controller' and 'etc'in it.

Within controller, I created a file called 'ReturnsController.php' and filled it as below -

  <?php class Returns_Returns_ReturnsController extends Mage_Core_Controller_Front_Action{
public function returnsAction()
{
    //Get current layout state
    $this->loadLayout();

    $block = $this->getLayout()->createBlock(
        'Mage_Core_Block_Template',
        'returns',
        array('template' => 'returns/returns.phtml')
    );

    $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
    $this->getLayout()->getBlock('content')->append($block);
    $this->_initLayoutMessages('core/session'); 
    $this->renderLayout();
}}

?>

Then in 'etc', I created a file 'config.xml' with content as below

<?xml version="1.0"?>
<config>
    <modules>
        <Returns_Returns>
            <version>0.1.0</version>
        </Returns_Returns>
    </modules>

    <frontend>
        <routers>
            <returns_returns>
                <use>standard</use>
                <args>
                    <module>Returns_Returns</module>
                    <frontName>returns</frontName>
                </args>
            </returns_returns>          
        </routers>              
    </frontend>

</config>

After this, I created a file in app/etc/modules as Returns_Returns.xml with content

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Returns_Returns>
            <active>true</active>
            <codePool>local</codePool>
        </Returns_Returns>
    </modules>    
</config>

Finally, I added a folder called 'returns' in app/design/frontend/et_oxynic/default/template. Created a file called 'returns.phtml' in it with test content

<?php 
if(Mage::getSingleton('customer/session')->isLoggedIn()):
  $name = Mage::getSingleton('customer/session')->getCustomer()->getName();
endif;
?>

<div class="box">
  <div class="box-content">
    <h4>
      <?php if(Mage::getSingleton('customer/session')->isLoggedIn()): echo "Welcome" . $name . "!"; ?>
      <?php else:  echo "Welcome, Guest!"; endif; ?>
    </h4>
    <p>We have successfully created a page using a magento module and router!</p>
  </div>
</div>

I cleared the cache from cache management from admin but I still get a 404 error.

Please help me out

0

You also need a layout file for your returns action at app/design/frontend/et_oxynic/default/layout/

Let's call it returns.xml ;)

<?xml version="1.0"?>
    <layout version="0.1.0">
        <returns_returns_returns>
            <reference name="content">
                <block type="core/template" name="returns" template="returns/returns.phtml" />
            </reference>
        </returns_returns_returns>
    </layout>
  • Thanks Kalpesh ! But its still not working..I cleared the cache as well after adding this file. Is there anything else I might be missing ? – Rishiraj Shrawat Jun 9 '15 at 15:43
  • I just noticed you said you created controller folder, it should be controllers – Kalpesh Jun 11 '15 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.