Magento 1.9 frontend custom page showing 404 page
-
11-12-2020 - |
Вопрос
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";
Something i miss here...!
Решение
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>