0

I am new to Magento. But i got a requirement. Below is the requirement:

  1. On the Frontend, user is having an option to select the theme from a given list of themes (Drop Down).
  2. Upon selecting a theme, the selected theme should be applied to the store dynamically.

Please help me with an example, how to implement this feature.

1

you can set theme like that on front-end..

Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml)
    ->setPackageName('default') //Name of Package
    ->setTheme('modern');
  • Hi. Thanks for your response. 1. I created a new module to change the theme dynamically. 2. After changing the theme as per above code, i redirected it to the home page. 3. But after redirecting to home page, theme is not updating. – Srinivasu Oct 5 '15 at 12:25
  • On Front end where should i place the code. – Srinivasu Oct 5 '15 at 12:28
  • magento.stackexchange.com/questions/17525/… follow this answer – Qaisar Satti Oct 5 '15 at 12:30
  • in your header.phtml file – Qaisar Satti Oct 5 '15 at 12:31
0

In order to fulfill,your require,

  • Need to create a custom controller
  • On dropdown changes,it will hit this controller's an action.
  • On this action,the selected theme will be selected and back you last page

If you want apply a theme to custom frontend ui then try this:

Mage::getSingleton('core/design_package') ->setPackageName($package) ->setTheme($theme);

This concept is like currency change.

controller code seems to like :

<?php
class Amit_Custommodule_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction(){
  $package=$this->getRequest()->getParam('package');
  $theme=$this->getRequest()->getParam('theme');

                Mage::getSingleton('core/design_package')
                    ->setPackageName($package)
                    ->setTheme($theme);
      // this code is redirec to you last page/same page
       $this->_redirectUrl($this->_getRefererUrl());          
  }
}
  • I did as you suggested, but once the page is redirecting the theme is changing to 'rwd' from 'default' – Srinivasu Oct 6 '15 at 9:48

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.