在Magento中获得皮肤路径? [英] Get skin path in Magento?

查看:47
本文介绍了在Magento中获得皮肤路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的Magento存储库提供了一些自定义PHP函数,这些函数存储在myfunc.php中,我需要在几个不同的.phtml文件中要求它.我该怎么办?

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 mean I can use an absolute path but that would be dirty and probably problematic when migrating to another server.

现在我坚持:

require('/home/myuser/public_html/app/design/frontend/default/mytheme/myfunc.php');

我如何以编程方式引用皮肤路径(/home/myuser/public_html/app/design/frontend/default/mytheme/)?

How do I refer to the skin path ( /home/myuser/public_html/app/design/frontend/default/mytheme/ ) programmatically?

推荐答案

Magento主题处理实际网址的方式是这样的(在视图局部文件中-phtml文件):

The way that Magento themes handle actual url's is as such (in view partials - phtml files):

echo $this->getSkinUrl('images/logo.png');

如果您需要磁盘上映像目录的实际基本路径,请使用:

If you need the actual base path on disk to the image directory use:

echo Mage::getBaseDir('skin');

这篇很棒的博客文章中提供了更多基本目录类型:

Some more base directory types are available in this great blog post:

http://alanstorm.com/magento_base_directories

这篇关于在Magento中获得皮肤路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆