zone de recherche s'affiche en double

zone de recherche s'affiche en double - PHP - Programmation

Marsh Posté le 02-04-2014 à 00:14:25    

Bonjour,
Je suis sous wordpress (3.8)
J'ai installé un plugin qui me permet d’insérer le search dans ma barre de menu horizontal.
Le problème c'est qu'il se rajoute automatiquement aussi dans mon menu vertical. (et cela j'en ai pas besoin.) et dans le menu de mon Footer (horreur je viens de m'en apercevoir)
 
Je me suis donc dit, que je devais transformer le code du plugin et lui dire que la zone de recherche ne dois s'afficher que dans le menu horizontal.
Mais voilà, j'y arrive pas, malgré quelques éssayes.
Voici mon code du plugin :
 

Code :
  1. <?php
  2. /*
  3. Plugin Name: Search box on Navigation Menu
  4. */
  5. add_filter('wp_nav_menu_items','add_search_box', 10, 2);
  6. function add_search_box($items, $args) {
  7.         ob_start();
  8.         get_search_form();
  9.         $searchform = ob_get_contents();
  10.         ob_end_clean();
  11.         $items .= '<li>' . $searchform . '</li>';
  12.     return $items;
  13. }
  14. ?>

 
Et voici le contenu de firebug lorsque je clique sur un la zone recherche de mon menu horizontal :
 

Code :
  1. <div id="content">
  2. <div id="content-inner" class="container clearfix">
  3. <div id="header" class="hb_sticky_nav clearfix">
  4. <div id="main-navigation-wrapper-sticky-wrapper" class="sticky-wrapper" style="height: 38px;">
  5. <div id="main-navigation-wrapper" class="navigation-class clearfix">
  6. <ul id="nav" class="menu clearfix sf-js-enabled">
  7. <li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-18 current_page_item menu-item-26">
  8. <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-390">
  9. <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-65">
  10. <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-64">
  11. <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-63">
  12. <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-613">
  13. <li>
  14. <form id="search-404" action="http://www.saphonyx.be/" method="get" role="search">
  15. <input id="search" type="text" name="s" placeholder="Search and hit enter...">
  16. <input id="submit-search" type="submit" value="">


 
 
Voici le code lorque je clique sur le search du menu vertical que je veux faire disparaitre :
 

Code :
  1. <div id="sidebar-page-wrapper" class="clearfix">
  2. <div id="main-content-with-sidebar" class="col-8">
  3. <div id="main-sidebar" class="col-4">
  4. <div id="main-sidebar-inner">
  5. <div id="dc_jqverticalmegamenu_widget-2" class="widget-item clearfix ">
  6. <div id="dc_jqverticalmegamenu_widget-2-item" class="dcjq-vertical-mega-menu">
  7. <ul id="menu-recherche" class="menu right">
  8. <li id="menu-item-34" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-34">
  9. <li id="menu-item-37" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-37 dc-mega-li">
  10. <li id="menu-item-156" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-156 dc-mega-li">
  11. <li id="menu-item-155" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-155">
  12. <li id="menu-item-154" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-154">
  13. <li id="menu-item-153" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-153">
  14. <li class="">
  15. <form id="search-404" action="http://www.saphonyx.be/" method="get" role="search">
  16. <input id="search" type="text" name="s" placeholder="Search and hit enter...">
  17. <input id="submit-search" type="submit" value="">


 
 
Si vous pouviez me donner des indices se serait super.
merci d'avance
Nicolas


Message édité par fly_in_the_sky le 02-04-2014 à 00:40:42
Reply

Marsh Posté le 02-04-2014 à 00:14:25   

Reply

Marsh Posté le 03-04-2014 à 09:57:16    

tente ça :

Code :
  1. <?php add_filter('wp_nav_menu_items','add_search_box', 10, 2);
  2.  
  3.  
  4. function add_search_box($items, $args) {
  5.   if ($args->theme_location == 'main_navigation') {//verifie qu'on est dans le bon contenant
  6.         ob_start();
  7.         get_search_form();
  8.         $searchform = ob_get_contents();
  9.         ob_end_clean();
  10.  
  11.     $items .= '<li class="searchbox">' . $searchform . '</li>';
  12.   }
  13.   return $items;   
  14.      
  15. }?>

Reply

Marsh Posté le 03-04-2014 à 10:03:51    

Merci j'éssaye de suite.
nico


Message édité par fly_in_the_sky le 03-04-2014 à 10:04:25
Reply

Marsh Posté le 03-04-2014 à 10:24:08    

Bon ca a fait planté le site, j'ai remis comme avant via le ftp.
Tu dis qu'il faut que je vérifié si je suis dans le bon contenant. peut - tu mieux m'expliquer comment vérifié ou mettre dans le bon contenant ?
Merci

Reply

Marsh Posté le 03-04-2014 à 10:41:15    

il faudrait ton code sur comment sont créées tes barres de menu horizontal, vertical, footer.

Reply

Marsh Posté le 03-04-2014 à 15:11:11    

C'est grâce au template, il y a un appel dans les templates qui appelle le header, et le footer.
 
voici le fichier header.php de mon thème.

Code :
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage Aegaeus
  5. */
  6. global $data, $post;
  7. ?>
  8. <!DOCTYPE HTML>
  9. <!-- START html -->
  10. <!--[if IE 8]>
  11. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); echo ' class="ie ie8"';?>>
  12. <![endif]-->
  13. <!--[if !IE]>-->
  14. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes();
  15. if(is_admin_bar_showing()) {
  16. echo ' style="margin-top:28 !important; "';
  17. }?>>
  18. <!--<![endif]-->
  19. <!-- START head -->
  20. <head>
  21. <?php if ( !is_404() ) print_meta_tags( get_the_ID() ); ?>
  22. <?php add_favicon(); ?>
  23. <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen" />
  24. <?php if($data['hb_use_custom_typography']){ ?>
  25. <!-- BEGIN Typography Styles from Theme Options -->
  26. <style type="text/css">
  27. body, a, ul li a { font-family: <?php echo $data['hb_body_font']['face']; ?>; font-size: <?php echo $data['hb_body_font']['size']; ?> !important; color: <?php echo $data['hb_body_font']['color']; ?>; font-weight: <?php echo $data['hb_body_font']['style']; ?> !important; }
  28. h1 { font-family: <?php echo $data['hb_h1_font']['face']; ?>; font-size: <?php echo $data['hb_h1_font']['size']; ?> !important; color: <?php echo $data['hb_h1_font']['color']; ?>; font-weight: <?php echo $data['hb_h1_font']['style']; ?> !important; }
  29. h2 { font-family: <?php echo $data['hb_h2_font']['face']; ?>; font-size: <?php echo $data['hb_h2_font']['size']; ?> !important; color: <?php echo $data['hb_h2_font']['color']; ?>; font-weight: <?php echo $data['hb_h2_font']['style']; ?> !important; }
  30. h3 { font-family: <?php echo $data['hb_h3_font']['face']; ?>; font-size: <?php echo $data['hb_h3_font']['size']; ?> !important; color: <?php echo $data['hb_h3_font']['color']; ?>; font-weight: <?php echo $data['hb_h3_font']['style']; ?> !important; }
  31. h4 { font-family: <?php echo $data['hb_h4_font']['face']; ?>; font-size: <?php echo $data['hb_h4_font']['size']; ?> !important; color: <?php echo $data['hb_h5_font']['color']; ?>; font-weight: <?php echo $data['hb_h5_font']['style']; ?> !important; }
  32. h5 { font-family: <?php echo $data['hb_h5_font']['face']; ?>; font-size: <?php echo $data['hb_h5_font']['size']; ?> !important; color: <?php echo $data['hb_h5_font']['color']; ?>; font-weight: <?php echo $data['hb_h5_font']['style']; ?> !important; }
  33. h6 { font-family: <?php echo $data['hb_h6_font']['face']; ?>; font-size: <?php echo $data['hb_h6_font']['size']; ?> !important; color: <?php echo $data['hb_h6_font']['color']; ?>; font-weight: <?php echo $data['hb_h6_font']['style']; ?> !important; }
  34. #nav li a{ font-family: <?php echo $data['hb_nav_font']['face']; ?>; font-size: <?php echo $data['hb_nav_font']['size']; ?> !important; color: <?php echo $data['hb_nav_font']['color']; ?>; font-weight: <?php echo $data['hb_nav_font']['style']; ?> !important; }
  35. #footer, #footer ul, #main-sidebar, #mai-sidebar ul { font-family: <?php echo $data['hb_widget_font']['face']; ?>; font-size: <?php echo $data['hb_widget_font']['size']; ?> !important; color: <?php echo $data['hb_widget_font']['color']; ?>; font-weight: <?php echo $data['hb_widget_font']['style']; ?> !important; }
  36. <?php if( $data['hb_custom_font_import'] ) { echo $data['hb_custom_font_import']; } ?>
  37. </style>
  38. <!-- END Typography Styles -->
  39. <?php } ?>
  40. <!--[if IE]>
  41. <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/font-awesome-ie7.css" type="text/css" media="all"/>
  42. <![endif]-->
  43. <!--[if lt IE 9]>
  44. <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  45. <![endif]-->
  46. <?php include ( HBTHEMES_INCLUDES . '/theme-options-styles.php' ); ?>
  47. <!-- Custom CSS -->
  48. <?php if ( $data['hb_custom_css_field'] ) { ?>
  49. <style type="text/css">
  50. <?php echo $data['hb_custom_css_field'] ; ?>
  51. </style>
  52. <?php } ?>
  53. <!-- Custom CSS END -->
  54. <?php wp_head(); ?>
  55. </head>
  56. <!-- END head -->
  57. <?php $body_kikkey = "";
  58. if ( $data['hb_include_to_top'] )
  59.  $body_kikkey = "kikkey-top";
  60. ?>
  61. <!-- START body -->
  62. <body <?php body_class($body_kikkey); ?>>
  63. <?php add_background_image ( get_the_ID() ); ?>
  64. <!-- START #wrapper -->
  65. <div id="wrapper" class="<?php
  66.  $space = "";
  67.  if ( !$data['hb_enable_bottom_line'] ){
  68.   echo 'hide-bottom-line ';
  69.  }
  70.  if ( !$data['hb_enable_main_shadow'] ){
  71.   echo 'no-shadow-layout ';
  72.  }
  73.  echo $data['hb_choose_layout_type'] . ' ';
  74.  if ( !is_page_title_enabled ( get_the_ID() ) ) {
  75.   echo 'page-no-title';
  76.   $space = " ";
  77.  }
  78.  $hb_page_sidebar_position = sanitize_title ( get_post_meta ( get_the_ID() , 'hb_page_sidebar_position' , true ) );
  79.  if ( is_archive() || is_category() || is_tag() || is_search() || is_author() || is_attachment() ) {
  80.   if ( strtolower ( $data['hb_archive_pages_sidebar_position'] ) != 'none' )
  81.    $hb_page_sidebar_position = $data['hb_archive_pages_sidebar_position'];
  82.  }
  83.  if ( page_has_sidebar ( get_the_ID() ) ) echo $space.$hb_page_sidebar_position;
  84. ?>">
  85. <?php add_map_dropdown(); ?>
  86. <!-- START #content -->
  87. <div id="content">
  88. <!-- START #content-inner -->
  89. <div id="content-inner" class="container clearfix">
  90. <?php add_theme_header(); ?>
  91. <?php
  92.  // check if landing page and main navigation is disabled
  93.  if ( get_current_template() == "page-landing.php" )  {
  94.   if ( get_post_meta ( get_the_ID() , 'hb_disable_main_navigation', true ) != "on" ){
  95.    add_theme_main_nav();
  96.   }
  97.  }
  98.  else
  99.   add_theme_main_nav();
  100. ?>
  101. <?php add_header_separator( get_the_ID() ); ?>
  102. <?php add_page_featured_image_slider( get_the_ID() ); ?>
  103. <!-- START #main-content -->
  104. <div id="main-content" class="clearfix" >
  105. <!-- START #main-inner-wrapper -->
  106. <div id="main-inner-wrapper" class="col-12 clearfix<?php if ( page_has_sidebar( get_the_ID() ) ) echo ' page-with-sidebar'; ?>">
  107. <?php add_page_title( get_the_ID() ); ?>
  108. <?php if ( !page_has_sidebar( get_the_ID() ) ) { ?>
  109. <!-- START #fullwidth-wrapper -->
  110. <div id="fullwidth-wrapper" class="section clearfix">
  111. <?php } else { ?>
  112. <!-- START #sidebar-page-wrapper-->
  113. <div id="sidebar-page-wrapper" class="clearfix">
  114. <!-- START #main-content-with-sidebar" -->
  115. <div id="main-content-with-sidebar" class="col-8">
  116. <?php } ?>
  117. <?php if ( get_post_meta ( get_the_ID() , 'hb_include_breadcrumbs' , true ) || is_archive() || is_search() ) hbthemes_breadcrumbs(); ?>


 
le fichier footer.php
 

Code :
  1. <?php
  2. /**
  3. * @package WordPress
  4. * @subpackage Aegaeus
  5. */
  6. global $data;
  7. ?>
  8. <?php if ( !is_attachment() ) { ?>
  9.  <?php if ( comments_open() ) { comments_template(); ?>
  10.   <div class="spacer"></div>
  11.  <?php } ?>
  12. <?php } ?>
  13. <?php if ( !page_has_sidebar( get_the_ID() ) ) { ?>
  14.  </div>
  15.  <!-- END #fullwidth-wrapper -->
  16. <?php } else { ?>
  17.  </div>
  18.  <!-- END #main-content-with-sidebar -->
  19.  <!-- START #main-sidebar -->
  20.  <div id="main-sidebar" class="col-4">
  21.   <!-- START #main-sidebar-inner -->
  22.   <div id="main-sidebar-inner">
  23.   <?php
  24.    if ( is_archive() || is_category() || is_tag() || is_search() || is_author() ) {
  25.     dynamic_sidebar ( __('Default Sidebar' , 'hbthemes' ) );
  26.    } else {
  27.     dynamic_sidebar( get_post_meta ( get_the_ID() , 'hb_page_sidebar_name' , true ) );
  28.    }
  29.   ?>
  30.   </div>
  31.   <!-- END #main-sidebar-inner -->
  32.  </div>
  33.  <!-- END #main-sidebar -->
  34.  </div>
  35.  <!-- END #sidebar-page-wrapper -->
  36. <?php } ?>
  37. </div>
  38. <!-- END #main-inner-wrapper -->
  39. </div>
  40. <!-- END #main-content -->
  41. <!-- START #footer -->
  42. <?php $hb_footer_class = array(
  43.    'footer-style-01.png'=>array('1'=>'col-3', '2'=>'col-3', '3'=>'col-3', '4'=>'col-3'),
  44.    'footer-style-02.png'=>array('1'=>'col-3', '2'=>'col-3', '3'=>'col-6', '4'=>'hidden'),
  45.    'footer-style-03.png'=>array('1'=>'col-6', '2'=>'col-3', '3'=>'col-3', '4'=>'hidden'),
  46.    'footer-style-04.png'=>array('1'=>'col-3', '2'=>'col-6', '3'=>'col-3', '4'=>'hidden'),
  47.    'footer-style-05.png'=>array('1'=>'col-4', '2'=>'col-4', '3'=>'col-4', '4'=>'hidden'),
  48.    'footer-style-06.png'=>array('1'=>'col-8', '2'=>'col-4', '3'=>'hidden', '4'=>'hidden'),
  49.    'footer-style-07.png'=>array('1'=>'col-4', '2'=>'col-8', '3'=>'hidden', '4'=>'hidden'),
  50.    'footer-style-08.png'=>array('1'=>'col-6', '2'=>'col-6', '3'=>'hidden', '4'=>'hidden'),
  51.    'footer-style-09.png'=>array('1'=>'col-3', '2'=>'col-9', '3'=>'hidden', '4'=>'hidden'),
  52.    'footer-style-10.png'=>array('1'=>'col-9', '2'=>'col-3', '3'=>'hidden', '4'=>'hidden'),
  53.    'footer-style-11.png'=>array('1'=>'col-12', '2'=>'hidden', '3'=>'hidden', '4'=>'hidden'),
  54.   );
  55.   $hb_footer_style = $data['hb_footer_layout'];
  56.   if ( !$hb_footer_style ) $hb_footer_style = 'footer-style-1.png';
  57.   $hb_footer_class_id = "four-column-footer";
  58.   switch ($hb_footer_style) {
  59.    case 'footer-style-01.png':
  60.     $hb_footer_class_id = "four-column-footer";
  61.    break;
  62.    case 'footer-style-02.png':
  63.     $hb_footer_class_id = "three-column-footer";
  64.    break;
  65.    case 'footer-style-03.png':
  66.     $hb_footer_class_id = "three-column-footer";
  67.    break;
  68.    case 'footer-style-04.png':
  69.     $hb_footer_class_id = "three-column-footer";
  70.    break;
  71.    case 'footer-style-05.png':
  72.     $hb_footer_class_id = "three-column-footer";
  73.    break;
  74.    case 'footer-style-06.png':
  75.     $hb_footer_class_id = "two-column-footer";
  76.    break;
  77.    case 'footer-style-07.png':
  78.     $hb_footer_class_id = "two-column-footer";
  79.    break;
  80.    case 'footer-style-08.png':
  81.     $hb_footer_class_id = "two-column-footer";
  82.    break;
  83.    case 'footer-style-09.png':
  84.     $hb_footer_class_id = "two-column-footer";
  85.    break;
  86.    case 'footer-style-10.png':
  87.     $hb_footer_class_id = "two-column-footer";
  88.    break;
  89.    case 'footer-style-11.png':
  90.     $hb_footer_class_id = "one-column-footer";
  91.    break;
  92.   }
  93. ?>
  94. <?php if ( $data['hb_disable_footer'] == false && ( get_current_template() != "page-landing.php" || ( get_current_template() == "page-landing.php" && get_post_meta ( get_the_ID() , 'hb_disable_footer_widgets' , true ) != "on" ) ) ){ ?>
  95.  <div id="footer" class="<?php echo $hb_footer_class_id; ?>">
  96.   <div class="arrow-down"></div>
  97.   <!-- START #footer-inned -->
  98.   <div id="footer-inner" class="container clearfix">
  99.   <?php
  100.    for( $i=1 ; $i<=4; $i++ ){
  101.     echo '<div class="' . $hb_footer_class[$hb_footer_style][$i] . ' widget-column">';
  102.     dynamic_sidebar('Footer ' . $i);
  103.     echo '</div>';
  104.    }
  105.   ?>
  106.   </div>
  107.   <!-- END #footer-inner -->
  108.  </div>
  109.  <!-- END #footer -->
  110. <?php } ?>
  111. </div>
  112. <!-- END #content-inner -->
  113. </div>
  114. <!-- END #content -->
  115. <?php if ( $data['hb_disable_copyright_line'] == false ) { ?>
  116.  <!-- START #bottom-line -->
  117.  <div id="bottom-line" class="container clearfix">
  118.      <div id="bottom-inner" class="col-12 clearfix">
  119.       <div id="copyright-line">
  120.              <?php echo $data['hb_copyright']; ?>
  121.             </div>
  122.    <?php
  123.     // check if landing page and footer navigation is disabled
  124.     if ( get_current_template() == "page-landing.php" ) {
  125.      if ( get_post_meta ( get_the_ID() , 'hb_disable_footer_navigation', true ) != "on" )
  126.       add_theme_footer_nav();
  127.     } else {
  128.      add_theme_footer_nav();
  129.     }
  130.    ?>
  131.          
  132.            
  133.      </div>
  134.     </div>
  135.     <!-- END #bottom-line -->
  136.     <?php } ?>
  137. </div>
  138. <!-- END #wrapper -->
  139. <?php if ( $data['hb_analytics_code'] ) { echo $data['hb_analytics_code']; } ?>
  140. <?php wp_footer(); ?>
  141. </body>
  142. <!-- END body -->
  143. </html>
  144. <!-- END html -->


 
le code du plugin mega menumenu verticale[b][/b] (que j'ai rajouter)

Code :
  1. <?php
  2. /*
  3.  Plugin Name: jQuery Vertical Mega Menu
  4.  Plugin URI: http://www.designchemical.com/blog [...] nu-widget/
  5.  Tags: jquery, flyout, mega, menu, vertical, animated, css, navigation, widget
  6.  Description: Creates a widget, which allows you to add vertical mega menus to your side columns using any Wordpress custom menu.
  7.  Author: Lee Chestnutt
  8.  Version: 1.3.3
  9.  Author URI: http://www.designchemical.com
  10. */
  11. global $registered_skins;
  12. class dc_jqverticalmegamenu {
  13. function dc_jqverticalmegamenu(){
  14.  global $registered_skins;
  15.  if(!is_admin()){
  16.   // Header styles
  17.   add_action( 'wp_head', array('dc_jqverticalmegamenu', 'header') );
  18.  }
  19.  add_action( 'wp_footer', array('dc_jqverticalmegamenu', 'footer') );
  20.  $registered_skins = array();
  21. }
  22. function header(){
  23.  echo "\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".dc_jqverticalmegamenu::get_plugin_directory()."/css/dcverticalmegamenu.css\" media=\"screen\" />";
  24.  // Scripts
  25.   wp_enqueue_script( 'jquery' );
  26.   wp_enqueue_script( 'jqueryhoverintent', dc_jqverticalmegamenu::get_plugin_directory() . '/js/jquery.hoverIntent.minified.js', array('jquery') );
  27.   wp_enqueue_script( 'dcjqverticalmegamenu', dc_jqverticalmegamenu::get_plugin_directory() . '/js/jquery.dcverticalmegamenu.1.3.js', array('jquery') );
  28. }
  29. function footer(){
  30.  //echo "\n\t";
  31. }
  32. function options(){}
  33. function get_plugin_directory(){
  34.  return WP_PLUGIN_URL . '/jquery-vertical-mega-menu';
  35. }
  36. };
  37. // Include the widget
  38. include_once('dcwp_jquery_vertical_mega_menu_widget.php');
  39. // Initialize the plugin.
  40. $dcjqverticalmegamenu = new dc_jqverticalmegamenu();
  41. // Register the widget
  42. add_action('widgets_init', create_function('', 'return register_widget("dc_jqverticalmegamenu_widget" );'));
  43. ?>


 
 
Merci


Message édité par fly_in_the_sky le 04-04-2014 à 11:40:15
Reply

Marsh Posté le 04-04-2014 à 09:45:48    

le dernier code c'est ton menu horizontal et seulement lui ?

Reply

Marsh Posté le 04-04-2014 à 11:37:51    

Escuse moi je me suis trompé.  Cest le menu vertical et seulement lui.
 
Le horizontal était compris dans mon thème.

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed