Set package and theme at run time in magento2

随声附和 提交于 2019-12-05 15:16:56

If you want to Set package and theme at run time in magento simply use this code snippet.

  1. create one function ex. changeTheme('Theme-name'); and run this function with your requirement

  2. add this function in your head.phtml after php start.

     function changeTheme($themeName)
     {
       Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml)
                        ->setPackageName('default') //Name of Package
                        ->setTheme($themeName); // Name of theme
     }
    

enjoy :)

Divya Bhalodiya

You can set your theme programmatically by using the following code :

Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml)
    ->setPackageName('default') //Name of Package
    ->setTheme('modern'); // Name of theme

http://roshanlal.in/magento/magento-programmatically-change-theme/#more-193

liyakat

You can write below code in action to set package and theme for the action:

Mage::getDesign()->setArea(‘frontend’) //Area (frontend|adminhtml)
    ->setPackageName(‘default’) //Name of Package
    ->setTheme(‘modern’); // Name of theme

You may write the code in layout handler to set theme:

<reference name=”root”>
    <action method=”setTheme”>
        <theme>modern</theme>
    </action>
</reference>

Change page layout:

<reference name=”root”>
    <action method=”setTemplate”>
        <template>page/1column.phtml</template>
    </action>
</reference>

I hope it will surely help you.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!