本文介绍了添加< style> < script>在Magento静态块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个静态块(标识符 mega_menu
)
I have a static block (Identifier is mega_menu
)
p>
It has some code like this:
<ul class="dropdown-menu" role="menu">
<li data-submenu-id="submenu-patas">
<div id="submenu-patas" class="popover">
<h3 class="popover-title">Patas</h3>
<div class="popover-content"><img src="img/patas.png"></div>
</div>
</li>
<li data-submenu-id="submenu-snub-nosed">
<div id="submenu-snub-nosed" class="popover">
<h3 class="popover-title">Golden Snub-Nosed</h3>
<div class="popover-content"><img src="img/snub-nosed.png"></div>
</div>
</li>
</ul>
在普通html文件中(从这里获得这个代码)有一些样式, this:
In the normal html file (from where I got this code) there are some styles and it's references like this:
<link href="css/bootstrap.css" rel="stylesheet"> --<--Reference
<style>
body {
padding-top: 60px;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet"> --<--Reference
<style>
.navbar .popover {
width: 400px;
-webkit-border-top-left-radius: 0px;
-webkit-border-bottom-left-radius: 0px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
overflow: hidden;
}
</style>
还有一些脚本和它的引用如下:
And also some scripts and it's references like this:
<script src="../jquery.menu-aim.js" type="text/javascript"></script> --<Reference
<script src="js/bootstrap.min.js" type="text/javascript"></script> --<--Reference
<script>
var $menu = $(".dropdown-menu");
.
.
.
$(document).click(function() {
// Simply hide the submenu on any click. Again, this is just a hacked
// together menu/submenu structure to show the use of jQuery-menu-aim.
$(".popover").css("display", "none");
$("a.maintainHover").removeClass("maintainHover");
});
</script>
所以我的问题是:
这些样式和脚本直接在静态块中?
如果没有如何添加这些样式和脚本的工作为特定的静态块(例如 mega_menu
here )?
Can I these styles and scripts directly in static block?
If no how can I add these styles and script with work for particular static block (e.g. mega_menu
here)?
推荐答案
从静态块调用phtml文件
call phtml file from static block
{{block type="core/template" template="page/html/YOUR_FILE_NAME.phtml"}}
并将您的代码写入YOUR_FILE_NAME.phtml
and write your code in YOUR_FILE_NAME.phtml
这篇关于添加< style> < script>在Magento静态块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!