Magento - 从管理文件链接到前端皮肤 js 文件
我已经在我的前端皮肤文件中使用 jQuery。我现在在管理 phtml 文件中添加了一些额外的功能,这也需要使用 jQuery。我不想包含它两次,但是假设我不知道前端正在使用什么主题包名称(因为显然这可以改变,所以我不知道如何动态链接到现有的 jQuery 文件)不希望它被硬编码)?
例如,我尝试了这个,但它给了我管理主题包名称,而不是前端包:
<?php
// Get the package name
$configData = Mage::getStoreConfig('design');
$package = $configData['package']['name'];
?>
有人吗?
I'm already using jQuery in my frontend skin files. I've now added some extra functionality in an admin phtml file, that also needs to use jQuery. I don't want to have to include it twice, but how can I link to the existing jQuery file dynamically, assuming I don't know what theme package name is being used on the frontend (because obviously that can change, so I don't want it hardcoded)?
For example, I tried this, but it gives me the admin theme package name, not the frontend package:
<?php
// Get the package name
$configData = Mage::getStoreConfig('design');
$package = $configData['package']['name'];
?>
Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,这似乎有效。我可以直接访问数据库,在 core_config_data 表中查找“design/package/name”,然后使用以下命令构建 js 文件的 url:
OK, this seems to be working. I can access the db directly, look for the "design/package/name" in the core_config_data table and then build the url to the js file using that:
对我来说帮助将 $storeId 设置为 1 而不是 0
for me helped to set $storeId as 1 not 0