我正在开发一个 bootstrap主题,我试图修改分配给下拉菜单/父母的类,但我不是好运。
我所做的任何更改都没有显示在前端 - 我已刷新缓存,登录/注销,我甚至尝试编辑实际的核心文件,但没有任何工作。
我已将navigation.phtml
复制到local/Mage/Catalog/Block/Navigation.phtml
,但仍无效。
我一路上都错过了什么?我不太清楚该怎么做。
答案 0 :(得分:1)
首先,据我所知,Navigation.phtml
中没有code/core/Mage/Catalog/Block/
。它是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
。
答案 1 :(得分:1)
如果你想将Magento 1.7.x转换为Bootstrap导航应对topmenu.phtml到你的主题:
*的magento /应用/设计/前端/ 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文件:
*的magento /皮肤/前端/ your_package / your_theme / JS / jQuery的脚本/的magento到自举-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可能会出现自我隐藏问题。 我通过编辑核心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()
度过愉快的一天。
答案 2 :(得分:0)
而不是编辑核心文件,我决定通过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中构建bootstrap多级下拉列表所需的类..