9

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.

Drew Hunter
  • 10,136
  • 2
  • 40
  • 49
shashank
  • 125
  • 1
  • 1
  • 7

5 Answers5

27

Current Package

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

Current Theme (frontend)

Mage::getSingleton('core/design_package')->getTheme('frontend')
Drew Hunter
  • 10,136
  • 2
  • 40
  • 49
  • 1
    Like @peter-a points out in his answer, 'frontend' is not one of the possible options for `getTheme()`. Use 'locale', 'layout', 'template', 'default' or 'skin'. Otherwise `getTheme()` will always return 'default'. – Mark van der Sanden Mar 25 '15 at 13:33
13

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'
Peter A
  • 374
  • 1
  • 5
  • 13
9

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')
Deus777
  • 1,816
  • 1
  • 20
  • 18
1

here the another way:

$package = Mage::getStoreConfig('design/package/name');
$skin_name = Mage::getStoreConfig('design/theme/skin');
Ansyori
  • 2,807
  • 3
  • 29
  • 37
0

Wanted to add this as comment, but you can also get it straight from the database with

SELECT * FROM core_config_data WHERE path="design/theme/skin";
SELECT * FROM core_config_data WHERE path="design/package/name";

That's probably more useful for admins than in use live, you should use the magento functions if you're designing a template or coding within magento.

Kirrus
  • 302
  • 2
  • 11