Question

Am creating frontend custom page it showing 404 page, my code's are following

app\etc\modules\SilverExchange_Declaration.xml

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

app\code\local\SilverExchange\Declaration\etc\config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <SilverExchange_Declaration>
            <version>0.1.0</version>
        </SilverExchange_Declaration>
    </modules>
    <global>
            <blocks>
                <silverexchange_declaration>
                    <class>SilverExchange_Declaration_Block</class>
                </silverexchange_declaration>
            </blocks>
        </global>
    <frontend>
        <routers>
            <declaration>
                <use>standard</use>
                <args>
                    <module>SilverExchange_Declaration</module>
                    <frontname>declaration</frontname>
                </args>
            </declaration>
        </routers>
        <layout>
            <updates>
                <declaration>
                    <file>declaration.xml</file>
                </declaration>
            </updates>
        </layout>
    </frontend>
</config>

app\code\local\SilverExchange\Declaration\controllers\IndexController.php

<?php  

class SilverExchange_Declaration_IndexController extends Mage_Core_Controller_Front_Action
{

    public function IndexAction()
    {
        echo "HI fill your Declaration here";
    }
    Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());die; 
}

app\code\local\SilverExchange\Declaration\Block\Declaration.php

<?php
class SilverExchange_Declaration_Block_Declaration extends Mage_Core_Block_Template {

}

app\design\frontend\coolbaby\default\layout\declaration.xml

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
  <declaration_index_index>
    <reference name="content">
      <block type="silverexchange_declaration/helloWorld" name="declaration_any_block" template="declaration/index.phtml" />
    </reference>
  </declaration_index_index>
</layout>

app\design\frontend\coolbaby\default\template\declaration\index.phtml

<?php
echo "Hi there";

link http://127.0.0.1/ramesh/sliver-exchange/declaration enter image description here

Something i miss here...!

Était-ce utile?

La solution

Your code contains several errors !

app\etc\modules\SilverExchange_Declaration.xml

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

app\code\local\SilverExchange\Declaration\etc\config.xml

...
<frontName>declaration</frontName>
...

app\design\frontend\coolbaby\default\layout\declaration.xml

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
    <declaration_index_index>
        <reference name="content">
            <block type="declaration/declaration" name="declaration_any_block" template="declaration/index.phtml" />
        </reference>
    </declaration_index_index>
</layout>

app\code\local\SilverExchange\Declaration\controllers\IndexController.php

<?php  

class SilverExchange_Declaration_IndexController extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}

To access your module: www.domaine.com/declaration

EDIT:

To set your layout to 1column:

<?xml version="1.0" encoding="UTF-8"?>
    <layout version="0.1.0">
        <declaration_index_index>
            <reference name="root">
                <action method="setTemplate"><template>page/1column.phtml</template></action>
                <action method="setHeaderTitle" translate="title" module="declaration"><title>Declaration</title></action>
            </reference>
            <reference name="content">
                <block type="declaration/declaration" name="declaration_any_block" template="declaration/index.phtml" />
            </reference>
        </declaration_index_index>
    </layout>
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top