ilyes kooli
ilyes kooli

Reputation: 12053

How to get Magento theme directory?

First, I was here but that doesn't help because

$this->getSkinUrl()

Is not what I want since it returns URL not path

Mage::getBaseDir('skin');

returns the skin base dir, they may be many themes there..

I want to determine the current theme base dir.

Upvotes: 2

Views: 9740

Answers (3)

ilyes kooli
ilyes kooli

Reputation: 12053

Here is how you can get the current them path

$_SERVER['DOCUMENT_ROOT'].parse_url($this->getSkinUrl(''),PHP_URL_PATH);

More details about parse_url

Upvotes: -4

Drew Hunter
Drew Hunter

Reputation: 10114

Try this:

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

Upvotes: 14

Vern Burton
Vern Burton

Reputation: 3210

There may be many themes, but it will be using whatever you have configured and it will go all the way to the package/theme that might have been used in System > Config > Design

If you are looking for dir,

Mage_Core_Model_Design_Package::getSkinBaseDir()

public function getSkinBaseDir(array $params=array())
{
    $params['_type'] = 'skin';
    $this->updateParamDefaults($params);
    $baseDir = (empty($params['_relative']) ? Mage::getBaseDir('skin').DS : '').
        $params['_area'].DS.$params['_package'].DS.$params['_theme'];
    return $baseDir;
}

public function updateParamDefaults(array &$params)
{
    if ($this->getStore()) {
        $params['_store'] = $this->getStore();
    }
    if (empty($params['_area'])) {
        $params['_area'] = $this->getArea();
    }
    if (empty($params['_package'])) {
        $params['_package'] = $this->getPackageName();
    }
    if (empty($params['_theme'])) {
        $params['_theme'] = $this->getTheme( (isset($params['_type'])) ? $params['_type'] : '' );
    }
    if (empty($params['_default'])) {
        $params['_default'] = false;
    }
    return $this;
}

Upvotes: -1

Related Questions