1

I need to create front-end custom page URL like this www.demo.com/declaration/success

I have tried but page is showing 404 error. My codes are the following

D:\xampp\htdocs\ramesh\sliver-exchange\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>

    <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>
    <global>
        <helpers>
            <declaration>
                <class>SilverExchange_Declaration_Helper</class>
            </declaration>
        </helpers>
        <blocks>
            <declaration>
                <class>SilverExchange_Declaration_Block</class>
            </declaration>
        </blocks>
    </global>
</config>

D:\xampp\htdocs\ramesh\sliver-exchange\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->getLayout()->getBlock("head")->setTitle($this->__("Declaration"));
            $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
      $breadcrumbs->addCrumb("home", array(
                "label" => $this->__("Home Page"),
                "title" => $this->__("Home Page"),
                "link"  => Mage::getBaseUrl()
           ));

      $breadcrumbs->addCrumb("demo", array(
                "label" => $this->__("declaration"),
                "title" => $this->__("declaration")
           ));

      $this->renderLayout();
    }

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

D:\xampp\htdocs\ramesh\sliver-exchange\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="root">
    <action method="setTemplate"><template>page/1column.phtml</template></action>
  </reference>
  <reference name="content">
    <block type="declaration/declaration" name="declaration_index" template="declaration/index.phtml" />
  </reference>
</declaration_index_index>


<declaration_index_success>
  <reference name="root">
    <action method="setTemplate"><template>page/1column.phtml</template></action>
  </reference>
  <reference name="content">
    <block type="declaration/declaration" name="declaration_success" template="declaration/success.phtml" />
  </reference>
</declaration_index_success>


</layout>

D:\xampp\htdocs\ramesh\sliver-exchange\app\design\frontend\coolbaby\default\template\declaration\success.php

<section class="container">
    <div class="std">
        <div class="page-title">
            <h1>Declaration Success</h1>
        </div>
    </div>
</section>
1
  1. Update your controller to : app\code\local\SilverExchange\Declaration\controllers\SuccessController.php

    <?php  
    class SilverExchange_Declaration_SuccessController extends Mage_Core_Controller_Front_Action
    {
        public function IndexAction()
        {
         ...
        }
    
  2. Update the layout handle to : app\design\frontend\coolbaby\default\layout\declaration.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <layout version="0.1.0">
    <declaration_success_index>
        ...
    </declaration_success_index>
    
  3. Dont forget the app/etc/modules/SilverExchange_Declaration.xml

    <config>
        <modules>
            <SilverExchange_Declaration>
                <active>true</active>
                <codePool>local</codePool>
            </SilverExchange_Declaration>
        </modules>
    </config>
    

Now you can call your url like this: www.domaine.com/declaration/success

  • You're welcome. – PЯINCƏ Oct 3 '17 at 12:25

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.