我有一個問題,響應菜單切換不擴展在我工作的網站上。基本上,當網站的大小調整到768px以下時,菜單將被替換爲菜單切換,當點擊/點擊時,它應該顯示兩個選項關於&商店。然而,點擊後什麼都沒有發生,它只是簡單地將#navigation添加到URL的末尾。PHP代碼破壞響應導航切換首頁
我已經設法縮小到我的index.php文件中的this plugin的一行代碼。
<?php if(sb_slides_display()){sb_slides_display();} ?>
這是一個簡單的WordPress網站,WooCommerce使用主題mystile。鏈接:http://bit.ly/1dvdeb0
如果我拿出上面的代碼,問題解決了,但當然滑塊不再被激活。任何想法爲什麼或如何修復?
而且,這裏是代碼的情況下:
<?php
// File Security Check
if (! function_exists('wp') && ! empty($_SERVER['SCRIPT_FILENAME']) && basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])) {
die ('You do not have sufficient permissions to access this page!');
}
?><?php
/**
* Index Template
*
* Here we setup all logic and XHTML that is required for the index template, used as both the homepage
* and as a fallback template, if a more appropriate template file doesn't exist for a specific context.
*
* @package WooFramework
* @subpackage Template
*/
get_header();
global $woo_options;
?>
<?php if(sb_slides_display()){sb_slides_display();} ?>
<?php if ($woo_options[ 'woo_homepage_banner' ] == "true") { ?>
<div class="homepage-banner">
<?php
if ($woo_options[ 'woo_homepage_banner' ] == "true") { $banner = $woo_options['woo_homepage_banner_path']; }
if ($woo_options[ 'woo_homepage_banner' ] == "true" && is_ssl()) { $banner = preg_replace("/^http:/", "https:", $woo_options['woo_homepage_banner_path']); }
?>
<img src="<?php echo $banner; ?>" alt="" />
<h1><span><?php echo $woo_options['woo_homepage_banner_headline']; ?></span></h1>
<div class="description"><?php echo wpautop($woo_options['woo_homepage_banner_standfirst']); ?></div>
</div>
<?php } ?>
<div id="content" class="col-full <?php if ($woo_options[ 'woo_homepage_banner' ] == "true") echo 'with-banner'; ?> <?php if ($woo_options[ 'woo_homepage_sidebar' ] == "false") echo 'no-sidebar'; ?>">
預先感謝任何幫助它不勝感激! :)
編輯:從控制檯錯誤未捕獲的類型錯誤JavaScript頁面:對象[對象的對象]無方法 'fitVids':
/*-----------------------------------------------------------------------------------*/
/* GENERAL SCRIPTS */
/*-----------------------------------------------------------------------------------*/
jQuery(document).ready(function($){
// Fix dropdowns in Android
if (/Android/i.test(navigator.userAgent) && jQuery(window).width() > 769) {
$('.nav li:has(ul)').doubleTapToGo();
}
// Table alt row styling
jQuery('.entry table tr:odd').addClass('alt-table-row');
// FitVids - Responsive Videos
jQuery(".post, .widget, .panel").fitVids();
// Add class to parent menu items with JS until WP does this natively
jQuery("ul.sub-menu").parents('li').addClass('parent');
// Responsive Navigation (switch top drop down for select)
jQuery('ul#top-nav').mobileMenu({
switchWidth: 767, //width (in px to switch at)
topOptionText: 'Select a page', //first option text
indentString: ' ' //string for indenting nested items
});
// Show/hide the main navigation
jQuery('.nav-toggle').click(function() {
jQuery('#navigation').slideToggle('fast', function() {
return false;
// Animation complete.
});
});
// Stop the navigation link moving to the anchor (Still need the anchor for semantic markup)
jQuery('.nav-toggle a').click(function(e) {
e.preventDefault();
});
// Add parent class to nav parents
jQuery("ul.sub-menu, ul.children").parents().addClass('parent');
});
如果發生在客戶端上,它更可能是一個JavaScript問題,而不是PHP問題。我猜想那一行是包含一些導致錯誤的javascript。如果我在Chrome中查看控制檯,會出現一個錯誤:未捕獲的TypeError:Object [object Object]沒有方法'fitVids''。我會先找出原因。 – Hobo
@Hobo感謝您的回覆。我看了一下,你在這裏說的是一樣的。我設法找到該錯誤正在討論的文件,但不幸的是,我對JavaScript沒有太多瞭解,所以我看不出有什麼問題。 這是我認爲它正在談論的代碼片段,我粘貼了上面的其餘部分。也許你可以擺脫一些光線,如果有什麼東西突出錯了? '// FitVids - Responsive Videos \t jQuery(「.post,.widget,.panel」).fitVids();' – Alexander
嘗試註釋掉該行。如果您的網站上沒有任何視頻,則可能無法使用(猜測)。否則,記下它(我猜是它的https://github.com/davatron5000/FitVids.js),將它保存在主題目錄中,並在'general.js'之前將其排入到WordPress中(即擁有'general.js '依靠它)。它似乎與您鏈接的插件無關 - general.js來自哪裏?你編碼了嗎?如果是這樣,你爲什麼添加該行?如果你從某處複製它,也許你忘了複製fitvids源代碼? – Hobo