Can I my current theme call in constructing In custom Magento extension?
public function _construct(){
$this->loadLayout();
$this->renderLayout();
}
public function indexAction(){
$this->loadLayout();
$this->renderLayout();
echo "see My Controller";
}
When I am call layout in index controller the it will display the my cuttent theme. and when I call in _construct then it's display magento default theme. why?
can you explain ? how to set my current theme in _construct() function magento extension
Solutions
You need to add
Mage::app()->loadArea($this->getLayout()->getArea());
in your constructor before loading the layout.
That line is needed so magento will know what area to load.
It works in an action because the action is called after preDispatch()
is called, and that's where the area is usually loaded.
It doesn't work in the constructor by default because the constructor is called prior to calling preDispatch()
magento theme falling back to default theme even after theme is changed in admin side
magento theme falling back to default theme even after theme is changed in admin side. I am trying to change theme from default to blank theme under default package . I tried clearing all cache and checked System > Configuration > GENERAL > Design > Themes > Layout, it is "blank" and System > Configuration > GENERAL > Design > Package > Current Pac...
Call current product in custom phtml file in Magento 2
On the product page I created a custom module to override the form.phtml file. I also added the option to include a new file called customFile.phtml when the user clicks on a button that is positioned under the product description. In this customFile.phtml file I am trying to retrieve the current product data but it doesn't work. I also injected th...
Magento 2: Custom theme extending Blank Theme and custom module?
First post on here, I've started developing a custom theme extending the blank theme and I'm just curious about making a module. I've started on a module and I've made some blocks & templates, and it all works well, however I'm not sure if I've done everything right. My module is 100% for the custom theme and nothing else, the module is in: And...