Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #679151

    I found this thread: “Sidebar Menu nested at 2nd level” – https://kriesi.at/support/topic/sidebar-menu-nested-at-2nd-level/
    I want to solve the same problem. In my sidebar the 2nd level is only after clicking on the menu item will be displayed to the 1st level. But the code does not work for me. I get this error:
    Parse error: syntax error, unexpected ‘add_theme_support’ (T_STRING) in /kunden/is-wodniok.de/user/niederau-neu/wordpress/wp-content/themes/enfold-child/functions.php on line 1
    This is the code of functions.php in the child-theme:

    
    // Custom submenu
    function custom_submenu(){
    ?>
    <script>
    jQuery(window).load(function(){ 
     var menu            = jQuery('#menu-item-947'),
         subMenu         = jQuery('#menu-item-947 .sub-menu li:has(ul)');
    
     subMenu.children("ul").addClass("submenu-hide");
     menu.find('li a').on('click', function(event) { 
    var parent = jQuery(this).parent();
            if (jQuery(this).parent().is('li:has(ul)')) {
                event.preventDefault();
                parent.siblings().find('ul.submenu-show').removeClass('submenu-show');
                parent.find('ul:first').toggleClass('submenu-show');                        
            } 
    });
    
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_submenu');
    ?>
    

    Can you help me? Thank you!

    #680903

    Hey MargitW,

    I’m very sorry I cannot relate your issue to the old ticket. Please elaborate what you are trying to achieve?

    Best regards,
    Vinay

    #681070

    Hey Vinay,

    I’m sorry that you could’nt understand my question.
    I have a custom menu in the sidebar. It has a first and a second level. Only I want to be visible the menu items of second level when I click on the menu item of the first level.
    Example:
    When I click of the main menu item “Tourism”, to first in the sidebar I want to be visible the menu items of the first level: In Example “restaurants”, “camping”, “sights” …. The second level is to be still invisible.
    Only when I click of the first level menu item – in example “sights” – I want to be visible the 2nd level menu items: “church”, “castle”, “mill”….
    I tryed the code from this thread: https://kriesi.at/support/topic/sidebar-menu-nested-at-2nd-level/, but it did’nt work.
    I hope, you can understand me now. If not, then I must to write later in German. My english is bad. I often use Google Translator :-(

    #681162

    Hi,

    Thank you for the clarification. I am happy to help you with this issue Please post us your login credentials (in the “private data” field), so we can take a look at your backend.

    Login credentials include:

    • The URL to the login screen.
    • A valid username (with full administration capabilities).
    • As well as a password for that username.
    • permission to deactivate plugins if necessary.

    Best regards,
    Vinay

    #681491

    Hi,

    Here the Login for the website. Please do not deactivate plugins, if it destroys the website. Thank you for your help!

    #682127

    Hi,

    We have added the below code to functions.php

    
    function custom_submenu(){
    ?>
    <script>
    jQuery(window).load(function(){ 
     var menu            = jQuery('.widget_nav_menu'),
         subMenu         = jQuery('.menu-item-has-children .sub-menu');
    
     subMenu.addClass("submenu-hide");
     menu.find('li a').on('click', function(event) { 
    var parent = jQuery(this).parent();
            if (jQuery(this).parent().is('li:has(ul)')) {
                event.preventDefault();
                parent.siblings().find('ul.submenu-show').removeClass('submenu-show');
                parent.find('ul:first').toggleClass('submenu-show');                        
            } 
        
    });
    
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_submenu');

    And the below css in child theme styles.css

    .submenu-hide{
    	display: none!important;
    }
    .submenu-show{
    	display: block !important;
    }

    Please review the site and let us know

    Best regards,
    Vinay

    #682239

    Thank you for your help! It already looks good.

    But with your code the submenu in the main menu also invisible ;-(
    So I changed the css-code:

    .widget_nav_menu .submenu-hide{
    	display: none !important;
    }
    .widget_nav_menu .submenu-show{
    	display: block !important;
    }

    Now the sumenu of the Main Menu remains visible.

    But there is yet another problem in the widget nav menu:
    If you click on the menu item in the first level, the submenu is visible. That’s right. But when the menu item also has a content page, then this contents page is not called, the link no longer works. Can you change that? That would be great.

    Incidentally, I have found that I always get errors when I change the functions.php with Notepad and FTP. I have only now seen that I can functions.php in WordPress editor edit. This works – comical.

    #683584

    Hi,

    Glad you sorted the submenu issue with custom css.

    - Level 1 (custom link)
    -- Level 2
    -- Level 2

    As I understand you need the menu to open the custom link when user click on Level 1 menu item is that correct?

    To do so in the code remove line ” event.preventDefault(); ” but then the user will be sent to the custom link and the browser will refresh and the submenu will be rendered useless.

    Hence we need to stop the default browser action if the menu item has a submenu and show the submenu option.

    Notepad may be adding extra characters while saving and uploading via FTP. Try to use a text editor like sublime text so you wont have any issue while editing and uploading files.

    Let us know if you have any questions.

    Best regards,
    Vinay

    • This reply was modified 8 years, 2 months ago by Vinay.
    #683632

    Oh shame. Then there is probably no solution. Then I have to remove the code again and leave the second level visible. Nevertheless, thanks for your help.

    #684464

    Hi,

    As an alternative you can add the parent menu link in submenu again by creating an extra menu item.
    Please feel free to get in touch with us if you have more questions.

    Best regards,
    Vinay

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