1

I've created an index.phtml page and it work on myWeb.id/brand link. Now I create edit.phtml on my brand folder but I can't access it on myWeb.id/brand/edit.phtml. My web says 404 not found. What should I do?

My module :

<?xml version="1.0"?>
<config>
  <modules>
    <myWeb_Brand>
      <active>true</active>
      <codePool>local</codePool>
      <version>0.1.0</version>
    </myWeb_Brand>
  </modules>
</config>

my brand.xml :

    <?xml version="1.0"?>   
    <layout version="0.1.0">   
      <brand_index_index>   
        <reference name="root">   
          <action method="setTemplate"><template>page/1column.phtml</template></action>   
        </reference>   
        <reference name="content">   
          <block type="brand/index" name="brand_index" template="brand/index.phtml"/>   
        </reference>   

    <reference name="product_list_toolbar">
            <action method="setTemplate"><template /></action>
        </reference>
      </brand_index_index> 



    </layout>  

my local block index.php

<?php   
class myWeb_Brand_Block_Index extends Mage_Catalog_Block_Product_List {   
}
?>

indexcontroller.php

<?php
class myWeb_Brand_IndexController extends Mage_Core_Controller_Front_Action{
    public function IndexAction() {

      $this->loadLayout();   
      $this->getLayout()->getBlock("head")->setTitle($this->__("Brand"));
            $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
      $breadcrumbs->addCrumb("home", array(
                "label" => $this->__("Home Page"),
                "title" => $this->__("Home Page"),
                "link"  => Mage::getBaseUrl()
           ));

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

      $this->renderLayout(); 

    }

}

Helper :

<?php
class myWeb_Brand_Helper_Data extends Mage_Core_Helper_Abstract
{
}

Config.xml :

<?xml version="1.0"?>
<config>
  <modules>
    <myWeb_Brand>
      <version>0.1.0</version>
    </myWeb_Brand>
  </modules>
  <frontend>
    <routers>
      <brand>
        <use>standard</use>
          <args>
            <module>myWeb_Brand</module>
            <frontName>brand</frontName>
          </args>
      </brand>
    </routers>
        <layout>
          <updates>
            <brand>
              <file>brand.xml</file>
            </brand>
          </updates>
        </layout>
  </frontend>
  <global>
    <helpers>
      <brand>
        <class>myWeb_Brand_Helper</class>
      </brand>
    </helpers>
    <blocks>
      <brand>
        <class>myWeb_Brand_Block</class>
      </brand>
    </blocks>
  </global>
</config> 
4
  • Please update layout handle that you are using? Commented Feb 27, 2017 at 5:55
  • show us some code to help you out.
    – Priyank
    Commented Feb 27, 2017 at 6:01
  • please check my codes @PrasantaHatui Commented Feb 27, 2017 at 6:38
  • I've added the codes @userpk Commented Feb 27, 2017 at 6:39

2 Answers 2

1

Add below code in brand.xml

<brand_index_edit>   
    <reference name="root">   
      <action method="setTemplate"><template>page/1column.phtml</template></action>   
    </reference>   
    <reference name="content">   
      <block type="brand/edit" name="brand_edit" template="brand/edit.phtml"/>   
    </reference>   
  </brand_index_edit>

add below code in indexcontroller.php

public function EditAction() {

  $this->loadLayout();   
  $this->getLayout()->getBlock("head")->setTitle($this->__("Brand"));
        $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
  $breadcrumbs->addCrumb("home", array(
            "label" => $this->__("Home Page"),
            "title" => $this->__("Home Page"),
            "link"  => Mage::getBaseUrl()
       ));

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

  $this->renderLayout(); 

  }

And create block class Edit.php and put below code:

<?php   
class myWeb_Brand_Block_Edit extends Mage_Catalog_Block_Product_List {   
}
?>
5
  • Still 404 not found :( Commented Feb 27, 2017 at 7:22
  • yes, i'm using that link, but nothing happen. and I'm trying to check by echo something on EditAction () but thats not work too Commented Feb 27, 2017 at 7:33
  • sorry use this url format myWeb.id/brand/index/edit Commented Feb 27, 2017 at 7:38
  • okay thanks it works, but can I make it to myWeb.id/brand/edit ? Commented Feb 27, 2017 at 7:44
  • You have to create url rewrite rule from backend Commented Feb 27, 2017 at 7:47
1

Try this code

<brand_index_edit>   
  <reference name="root">   
    <action method="setTemplate"><template>page/1column.phtml</template></action>   
  </reference>   
  <reference name="content">   
    <block type="brand/edit" name="brand_edit" template="brand/edit.phtml"/>   
  </reference>   
</brand_index_edit> 

in your url

www.yourwebsite.com/brand/edit/

Make sure you have Edit.php(Block File) and edit.phtml (Template File) placed Properly.

3
  • I follow your instruction to create Edit.php block file and my edit.phtml placed properly. But nothing happen. Still 404 not found Commented Feb 27, 2017 at 7:05
  • First check if its going to your edit controller action. If it does then check if the block it getting called by printing something in _constructor. Then finally check if your phtml file is getting called.
    – Priyank
    Commented Feb 27, 2017 at 7:09
  • should I create a new controller? I just have IndexAction() in my IndexController.php Commented Feb 27, 2017 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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