Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current theme name in Magento

Tags:

php

magento

In magento i am trying to get current theme or package name but not found anything. I used getSkinUrl(') but it's return skin path not package or theme name.please help me how i can get theme or package name.

like image 308
shashank Avatar asked Jun 22 '12 11:06

shashank


4 Answers

Current Package

Mage::getSingleton('core/design_package')->getPackageName()

Current Theme (frontend)

Mage::getSingleton('core/design_package')->getTheme('frontend')
like image 84
Drew Hunter Avatar answered Nov 10 '22 03:11

Drew Hunter


Please note that the above answer by @Drew Hunter is not entirely correct. While getTheme() is the desired function call, the string 'frontend' is not an accepted parameter for this method. The only allowed values for this method are:

  • locale
  • layout
  • template
  • default
  • skin

That is to say, the correct usage of this function is one of the following lines:

Mage::getSingleton('core/design_package')->getTheme()
Mage::getSingleton('core/design_package')->getTheme('locale')
Mage::getSingleton('core/design_package')->getTheme('layout')
Mage::getSingleton('core/design_package')->getTheme('template')
Mage::getSingleton('core/design_package')->getTheme('default')
Mage::getSingleton('core/design_package')->getTheme('skin')

Failing to use the method in this manner will always return the string 'default'.

Unexpected Results

Incorrect usage will produce logic errors. An example of this is if you have a 'Matched Expression' defined to specifically target mobile devices.

Mage::getSingleton('core/design_package')

references the following class

Mage_Core_Model_Design_Package

By looking at the 'getTheme()' method in this class you will notice possible options you can pass this method, they are 'locale', 'layout', 'template', 'default' and 'skin'.

Therefore, if a particular store had 'Matched Expression' for 'template' like the following

iPhone|iPod|Mobile|mobile > mobile

The following may happen

Mage::getSingleton('core/design_package')->getTheme('frontend') RETURNS 'default'
Mage::getSingleton('core/design_package')->getTheme('template') RETURNS 'mobile'
like image 40
Peter A Avatar answered Nov 10 '22 03:11

Peter A


Since

Mage::getSingleton('core/design_package')

is equivalent of

Mage::getDesign()

Drew's examples can be shorten to:

Mage::getDesign()->getPackageName()

and

Mage::getDesign()->getTheme('frontend')
like image 9
Deus777 Avatar answered Nov 10 '22 04:11

Deus777


here the another way:

$package = Mage::getStoreConfig('design/package/name');
$skin_name = Mage::getStoreConfig('design/theme/skin');
like image 1
Ansyori Avatar answered Nov 10 '22 04:11

Ansyori