Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1484724

    Hi,

    how can I use the Burger-Menu in a widget or in the footer or anywhere on the site? Is there a shortcode to implement it?

    “Different menu for different pages” isn’t helpful because its site-specific.

    I need a solution to show the Burger-Menu (and/or the Desktop-Menu!) within the footer and/(!)/or sidebars ((optional within a accordeon). Therefore I need a general solution I can use flexible…

    Thanks

    #1484743

    Hey slikslok,

    Did you try the Navigation Menu widget?

    Best regards,
    Rikard

    #1484752

    Sure, but thats a complete list of all sites. I want a menu like in the header or the burger, which means, subpages are within a submenu.

    #1484764

    Hi,

    There’s nothing like that in the theme by default unfortunately, maybe there is a plugin available in the WordPress plugin repository which would implement that for you?

    Best regards,
    Rikard

    #1484770

    Hi, please ask your programmers: There MUST be solution! What about using something like wp_nav_menu put it in an array and create a shortcode from there? Enfold itselfs uses this to create menues so why shouldn’t it be possible to create a shortcode with a menu?

    Thanks

    #1484855

    Hi,

    I’m sure there is a solution, but it would be out of scope of theme support. If you need someone to create this customisation for you, then we recommend that you reach out to Codable.

    Best regards,
    Rikard

    #1484863

    First : i’m using this shortcode to insert a named menu from wordpress menu options:

    maybe an example of mine helps you to find your own way to do it.

    function print_menu_shortcode($atts, $content = null) {
        extract(shortcode_atts(array( 'name' => null, ), $atts));
        return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
    }
    add_shortcode('menu', 'print_menu_shortcode');

    maybe the menu-shortcode will help you – and f.e. here : https://jonsuh.com/hamburgers/

    there are some plugins to test. …

    #1484864

    or a little more choice:

    <?php
    function custom_named_menu_shortcode( $atts ) {
        extract( shortcode_atts( array(
            'name' => '', // Default to an empty menu name
            'class' => 'custom-menu', // Default CSS class
            'depth' => 0, // Default depth (0 for unlimited)
        ), $atts ) );
    
        if ( ! empty( $name ) ) {
            return wp_nav_menu( array(
                'menu'            => $name,
                'menu_class'      => $class,
                'container'       => 'nav', // You can change this to 'div', false, etc.
                'container_class' => $class . '-container',
                'echo'            => false, // Important: returns the menu HTML instead of printing it
                'depth'           => $depth,
            ) );
        }
        return ''; // Return empty if no menu name is provided
    }
    add_shortcode( 'named_menu', 'custom_named_menu_shortcode' );
    ?>
    

    and use the shortcode like that: [named_menu name="your-menu-name" class="my-custom-menu" depth="2"]

    #1484886

    Thanks a lot Guenni,

    If i use the first code, the output an the frontpage is just “[print_menu_shortcode]”. So the shortcode obviously is not replaced by the array. What do you think, is the variable “menu” not filled? How can I check where the problem is? Does “menu” correspond with “Main Menu” of wordpress? How to fill menu? Or is it a WP-Standard variable automatically filled?

    Thanks!

    #1484907

    you find the menu names on :

    #1484908

    you can see here an example on using that shortcode including the existing classes from enfold to handle a hamburger menu – if you look to the DOM – it is very nearby the setup from : https://jonsuh.com/hamburgers/
    because all scripts are allready implemented to enfold – you have to find a way how to insert that DOM Structure

    <button class="hamburger hamburger--collapse" type="button">
      <span class="hamburger-box">
        <span class="hamburger-inner"></span>
      </span>
    </button>
    

    but try to find a plugin ( yes the good ones are not free) that handles the hamburger insertion with a given WordPress menu.

    #1484919

    Thanks.
    Seems like I don’t have been clearly enough. I’m not looking for just a burger menu (Ialready have one). I want to implement a second (not s submenu!) Menu in the footer or a sidebar-widget which function as a sitemap. Unfortunately, using the existing nav/menu-widget within Enfold, ALL sites are listed (depth = 0). But I look for a solution that behaves (!) like the main or burger-menu, so only parent-pages on root level are shown (but clickable for second, third, level).
    So all I need is shortcode (or php-snippet), with which I can place a copied menu in the footer/sidebar which increments the main menu.
    Somehting like you posted above. But when I use the shortcode, html only renders the shortcode litearrly in the DOM instead a filled menu.

    Hope its clearer now.

    I found and tried snippets for adding menu also, like in your screenshot. But how to implement them in the html code? I always get back the plain shortcode.
    An example:

    
    function fhw_register_new_menu() {
        register_nav_menu( 'sitemap', __( 'Sitemap' ) );
    }
    add_action( 'init', 'fhw_register_new_menu' );
    

    and tried to get frontsidfe-output width

    
    wp_nav_menu( array( 'theme_location' => 'sitemap' ) );
    

    and put this as code in a widget or html-blok, but nothing happend, only the shortcode is given literally (like described above).

    Can’t believe that I nee a plugin for that simple question: how to copy the existing main menu in a shortcode which I can use everywhere ion the page…….

    #1485004

    see here on very small screens: https://webers-web.info/datenschutz/
    that sidebar menu on the left goes to a hamburger on top right on small screen width.

    you see on the link above (https://jonsuh.com/hamburgers/) – and (on enfold main burger DOM ) what are the class names – i used them too – because then a predefined look is allready present.:
    and the script to manage the burger is allready loaded

    (page-id-3 – is my privacy page)

    add_action('ava_after_main_menu', function() {
    	if ( is_page(3)){
    		echo '<nav class="datenschutz-menu" role="navigation">';
    		echo '<div class="container av-menu-mobile-active">';
    		echo '<a href="#" class="mobile_menu_toggle no-scroll" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"><span class="av-current-placeholder">Datenschutz</span>';
    		echo '<span class="subnav-hamburger subnav-hamburger--spin-r"><span class="subnav-hamburger-box"><span class="subnav-hamburger-inner"></span></span></span>';
    		echo '</a>';
    		echo do_shortcode('[menu name="datenschutz"]');	
    	 	echo '</div>';
    		echo '</nav>';
    	}
    });

    on that line: echo do_shortcode('[menu name="datenschutz"]'); you see the usage of that menu shortcode

    now i got that extra subnav-hamburger (this name is set by me – it only reminds me that this is subnavigation on privacy page )
    now i have to have the same behaviour on that second burger menu:

    function subnav_hamburger_first(){
    if(is_page(array( 3))){ 
    ?>
    <script>
    (function($){
        var $subham = $(".mobile_menu_toggle");
        $subham.on("click", function(a) {
    		$subham.find(".subnav-hamburger").toggleClass("is-active");
    		$subham.next(".menu-datenschutz-container").find('#menu-datenschutz').toggleClass("av-open-submenu");
        });
    	$('#menu-datenschutz li').on("click", function(b) {
    		$(this).addClass('selected').siblings().removeClass('selected');
    		$(this).parents('#menu-datenschutz').toggleClass('av-open-submenu');
    		$(this).parents('.av-menu-mobile-active').find('.subnav-hamburger').toggleClass('is-active');
    	});
    })(jQuery);
    </script>
    <?php
    }}
    add_action('wp_footer', 'subnav_hamburger_first');

    This is not a trivial request, which is why there are several paid plugins available. To grasp the complexity of a multilevel burger menu, take a look at the avia-snippet-hamburger-menu.js code.

    #1485008

    so it should be possible to have a burger menu on placing f.e. a code-block element with html code:

    <nav class="datenschutz-menu" role="navigation">
      <div class="container av-menu-mobile-active">
        <a href="#" class="mobile_menu_toggle no-scroll" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello">
          <span class="av-current-placeholder">Datenschutz</span>
          <span class="subnav-hamburger subnav-hamburger--spin-r">
            <span class="subnav-hamburger-box">
              <span class="subnav-hamburger-inner"></span>
            </span>
          </span>
        </a>
        [menu name="datenschutz"] 
      </div>
    </nav>

    and then influencing it by:

    function subnav_hamburger_first(){
    ?>
    <script>
    (function($){
        var $subham = $(".mobile_menu_toggle");
        $subham.on("click", function(a) {
    		$subham.find(".subnav-hamburger").toggleClass("is-active");
    		$subham.next(".menu-datenschutz-container").find('#menu-datenschutz').toggleClass("av-open-submenu");
        });
    	$('#menu-datenschutz li').on("click", function(b) {
    		$(this).addClass('selected').siblings().removeClass('selected');
    		$(this).parents('#menu-datenschutz').toggleClass('av-open-submenu');
    		$(this).parents('.av-menu-mobile-active').find('.subnav-hamburger').toggleClass('is-active');
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'subnav_hamburger_first');


    and a lot of css then

    see on : https://webers-web.info/maps/

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.