我正在开发一个引导主题,我试图修改分配给下拉菜单/父母的类,但我没有太多的运气。
我所做的任何更改都不会显示在前端-我已经刷新了缓存,登录/退出,我甚至尝试编辑实际的核心文件,但没有任何工作。
我已经复制了navigation.phtml
到local/Mage/Catalog/Block/Navigation.phtml
,但仍然不能工作。
我是否错过了什么?我不太确定该怎么办。
首先,据我所知,code/core/Mage/Catalog/Block/
中没有Navigation.phtml
。它是Navigation.php
代替(Magento 1.7.x)。
local
中创建一个精确的副本,它可能在更新后不起作用。
如果你想创建一个下拉菜单,你需要编辑app/design/frontend/base/default/
文件,在app/design/frontend/yourtheme/default/
文件夹中创建一个副本。
顶部菜单位于app/design/frontend/base/default/catalog/navigation/top.phtml
。如需详细查看,请打开System>Configuration>Developer>Debug
中的模板路径提示。
如果你想转换Magento 1.7。x引导导航处理顶部菜单。
*线上购物/app/设计/前端/your_package/your_theme/模板/页面/html/topmenu.phtml *
添加jQuery代码:<script type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready(function ($) {
$("#nav").magentoBootstrapNavigation();
});
/*]]>*/
</script>
你会得到像这样的东西:
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Top menu for store
*
* @see Mage_Page_Block_Html_Topmenu
*/
?>
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<ul id="nav" class="nav navbar-nav">
<?php echo $_menu ?>
</ul>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(document).ready(function ($) {
$("#nav").magentoBootstrapNavigation();
});
/*]]>*/
</script>
<?php endif ?>
然后通过local.xml添加js文件
<!-- jQuery scripts -->
<action method="addItem"><type>skin_js</type><script>js/jquery-scripts/magento-to-bootstrap-navigation.js</script></action>
创建js文件
*线上购物/皮/前端/your_package/your_theme/js/jquery脚本/magento-to-bootstrap-navigation.js *
打开magento-to-bootstrap-navigation.js
/*
* Convert default Magento navigation to Bootstrap navigation
*/
(function ( $ ) {
$.fn.magentoBootstrapNavigation = function() {
var menu = function(){
var nav = $(this);
nav.find(".parent")
.addClass("dropdown")
.children("a").addClass("dropdown-toggle").attr("data-toggle", "dropdown").append( ' <b class="caret"></b>')
.next().addClass("dropdown-menu");
};
return this.each(menu);
};
}( jQuery ));
这一切。
PS:你可以得到问题的自我隐藏。btn-group。我通过编辑core Bootstrap dropdown.js文件来解决这个问题:
* path_to_your_bootstrap/引导/js/dropdown.js *
打开并查找行:
$parent.removeClass('open').trigger('hidden.bs.dropdown')
并替换为:
//$parent.removeClass('open').trigger('hidden.bs.dropdown')
$parent.removeClass('open').trigger('hidden.bs.dropdown').show()
祝你今天愉快。
我决定用jQuery代替编辑核心文件…
<script type="text/javascript">
jQuery('.parent').addClass('dropdown');
jQuery('a.level-top').addClass('dropdown-toggle');
jQuery('li.parent ul').addClass('dropdown-menu');
jQuery('li.level1 ul').wrap('<li class="dropdown-submenu" />');
jQuery('ul.nav li.dropdown').hover(function() {
jQuery(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn();
}, function() {
jQuery(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut();
});
</script>
我通过jQuery添加了所需的类,并使用。wrap将下拉子菜单包裹在
周围。第二部分是将点击打开子菜单改为悬停打开子菜单。
现在一切都在工作,并有所需的类建立一个引导多级下拉菜单在magento..