Get skin path in Magento?

后端 未结 6 1320
面向向阳花
面向向阳花 2020-12-14 06:01

I have a few custom PHP functions for my Magento store that I stored in myfunc.php and I need to require it from in a few different .phtml files. How do I do that?

I

6条回答
  •  有刺的猬
    2020-12-14 06:30

    First note that

    Mage::getBaseDir('skin')
    

    returns only path to skin directory of your Magento install (/your/magento/dir/skin).

    You can access absolute path to currently used skin directory using:

    Mage::getDesign()->getSkinBaseDir()
    

    This method accepts an associative array as optional parameter to modify result.

    Following keys are recognized:

    • _area frontend (default) or adminhtml
    • _package your package
    • _theme your theme
    • _relative when this is set (as an key) path relative to Mage::getBaseDir('skin') is returned.

    So in your case correct answer would be:

    require(Mage::getDesign()->getSkinBaseDir().DS.'myfunc.php');
    

提交回复
热议问题