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.
Current Package
Mage::getSingleton('core/design_package')->getPackageName()
Current Theme (frontend)
Mage::getSingleton('core/design_package')->getTheme('frontend')
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:
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'
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')
here the another way:
$package = Mage::getStoreConfig('design/package/name');
$skin_name = Mage::getStoreConfig('design/theme/skin');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With