Viewing 23 posts - 1 through 23 (of 23 total)
  • Author
    Posts
  • #1224942

    Hey guys!

    How do I make the Full Width SubMenu Sticky on Mobile?

    #1224962

    only the submenu or do you like to have the header with burger fixed too?

    #1224970

    Hi! :)

    Right now the Main Menu on Desktop & the Burger Menu on Mobile is Sticky (which is great). I love how it’s already set up.

    I would also like the Main Menu and the SubMenu to both be sticky on this page (please see Private Section)

    #1225067

    Hi,

    Please refer to the following:

    sticky submenu in mobile

    Specifically Victoria’s post.

    Best regards,
    Jordan Shannon

    #1225108

    I do not see your site link – cause i’m participant as you – to give better advice it would be nice to know more about your header settings.

    Well i guess this is not quiet simple as some like to have it.
    To get the sticky header even on mobile and on transparency header this is just
    quick css:
    ( i have on most of my installations the 990 break point for burger menu so: )

    @media only screen and (max-width: 989px) {
      .responsive #top #wrap_all #header .container {
        width: 90%;
        max-width: 90%;
      }
       
      #header {
        position: fixed !important;
        height: 80px !important;
        max-height: 80px !important;
      }
      
      .responsive.html_mobile_menu_tablet #top #wrap_all .av_header_transparency {
        background-color: transparent;
      }
      
      .responsive #top .av-logo-container ,
      .responsive #top .logo a,
      .responsive #top .logo img {
        height: 80px !important;
        max-height: 80px !important;
      }
      
      .responsive #top .av-main-nav .menu-item-avia-special a {
        height: 80px !important;
        line-height: 80px !important;
      }
    }

    __________________________ Just for Info – if you only interested in the solution skip to the next post ________________

    The sticky state when burger is active depends on the menu.js and the condition for :
    if( burger_menu.is(":visible")
    my search here on the board resulted unfortunately only in hits, which commented out this condition, which if you test this of course does not lead to the goal.
    so we had to find a calculation for that case – this can be found out more or less quickly – my solution is:

    if( burger_menu.is(":visible") && (scrolled + modifier > top_pos) ){
    	this.css({top: header.Height() , position: 'fixed !important'}); fixed = true;
    }

    Info: i first had the header.outerHeight() – but with that i had a 1px difference on scrolling on – do not know why.

    So far so good, but if you want to use a hamburger for the submenu in the responsive case, what is calculated in the script is unfortunately overwritten by the menu.css by setting values to !important.
    Even the calculated inline style could not overwrite these settings because the selector is more specific f.e:

    /**** from original menu.css - each break point (switch ) has these rules set to !important  *********/
    @media only screen and (max-width: 989px){
    	.responsive #top .av-switch-990.av-submenu-container{top: auto !important; position: relative !important; height:auto; min-height:0; margin-bottom: -1px;}
    }

    so we had to get rid of the important setting – thats why we need to have an own child-theme menu.css

    #1225113

    So my solution is to have all three alb files concerning to submenu in the child-theme shortcodes folder
    Activate the usage of child-theme shortcodes instead of the parent files with this in child-theme functions.php

    add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths){
    $template_url = get_stylesheet_directory();
      array_unshift($paths, $template_url.'/shortcodes/');
      return $paths;
    }
    // End of child-theme shortcodes loading snippet

    and download all three files from pastebin here ( based on enfold 4.7.5) :
    menu.php : https://pastebin.com/dl/CudTKvh1 and look
    menu.js : https://pastebin.com/dl/mTtFgR8K and look
    menu.css : https://pastebin.com/dl/Ckpa9z7w and look

    create a child-theme shortcodes folder via ftp and upload all files to that directory.

    i had to set on that in quick css :

    @media only screen and (max-width: 989px) {
    	#top .sticky_placeholder {
    	  position: absolute;
    	}
    }

    But this may be due to the fact that this test website has so many settings in functions.php and quick css that it was overwritten.

    Result f.e.: https://webers-testseite.de/transparent-header/
    You can see there both ( all three ) cases inbetween 480 and 990 i have submenu and under 480 hamburger.
    And: if there are more than one submenu the lower one gets sticky too if comes to the top.

    #1225169

    Perfect! Thank you!

    #1225174

    Not too complex ?
    If you need additonal help – tell me

    #1225262

    Hi Courtney,

    Glad you got it working for you with Guenni007’s solution! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1342886

    Hey Guenni, since Enfold changed parts of the shortcode behaviour in Version 4.8.9 I changed your filter from this post to:

    add_filter('ava_builder_shortcode_files_loaded', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths){
    $template_url = get_stylesheet_directory();
      array_unshift($paths, $template_url.'/shortcodes/');
      return $paths;
    }

    I added your modifications to the latest theme files (Version 4.9) and it works as expected.

    If anyone wants to do the same just remember the correct filter.

    • This reply was modified 2 years, 8 months ago by spooniverse.
    #1342979

    hm – i can not believe this – because what i see on class-template-builder.php on line : 675 – this ava_builder_shortcode_files_loaded
    is not a filter – the filter is still: avia_load_shortcodes

    #1342980

    Thought so too but I tested it with your code and the files did not load correctly …

    #1342985

    now i have made the changes to Enfold 4.9 files:

    and download all three files from pastebin here ( based on enfold 4.9) :
    menu.php : lookdownload
    menu.js : lookdownload
    menu.css : lookdownload

    see: https://webers-testseite.de/transparent-header/

    ( with child-theme shortcodes loading as mentioned in my first post – see: https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb )

    again here my question to the devs : is it realy necessary to have on menu.css set these rules ( top and position ) for media-query to be !important ?
    f.e. .responsive #top .av-switch-990.av-submenu-container{top: auto; position: relative; height:auto; min-height:0; margin-bottom: -1px;}
    ___________
    and maybe again the question, if new filters and actions are introduced ( they also appear in the changelog ) can you give an example for the application on f.e.: Github – maybe in the comment what it is meant for. Thanks

    #1342987

    On my end it worked with the pictures too but content in the color sections lost its custom styling. After I changed to ava_builder_shortcode_files_loaded it was as shown in your example. At first I thought it was a problem with the older template files, thats why I made your changes in the 4.9 files again, but the problem was still there. So you still loaded the /shortcodes folder with the code form the documentation?

    add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths)
    {
      $template_url = get_stylesheet_directory();
          array_unshift($paths, $template_url.'/shortcodes/');
    
      return $paths;
    }

    If the “!important” was omitted in parent theme it would be sufficient to only load the menu.js in the child theme, correct?

    #1343099

    i use all three files – the php file is only necessary because we had to load the child-theme css and js file.
    in the css parent file there are some settings to be !important. This is not possible to overwrite from external ( quick css ) css.

    #1343105

    I understand that. The question was if we would just have to load menu.js in the child theme if in the parent theme were no !important-rules?

    #1343431

    Hi,

    The correct filter to create new shortcode paths is still avia_load_shortcodes. The ava_builder_shortcode_files_loaded is actually a hook, not a filter, so you cannot use that to adjust the shortcode paths directly. Unfortunately, your questions above is a bit unclear. Would you mind elaborating a bit in a new thread or ticket?

    Best regards,
    Ismael

    #1343467

    Hey Ismael, I don’t know why, but in my tested installation only this code works as expected:

    add_filter('ava_builder_shortcode_files_loaded', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths){
    	$template_url = get_stylesheet_directory();
      	array_unshift($paths, $template_url.'/shortcodes/');
      	return $paths;
    }

    The code from the documentation does interfer with loading the correct stylesheet for the rest of the page …

    My question was directed @Guenni007, I just wanted to understand his note to the devs better (see post-1342985). I just wanted to know if it would be sufficient to only load the menu.js in the child theme if the “!important” was omitted in parent theme.

    #1343561

    Hi,

    That code should not be working because ava_builder_shortcode_files_loaded is not a valid filter. Are you sure that the avia_load_shortcodes was not added to the site?

    Best regards,
    Ismael

    #1343581

    Strange. Only in this way it works as intended. The one other code that interferes with styles and the child theme is this (from Guenni007 too):

    add_action( 'wp_enqueue_scripts', 'wp_change_sticky_header_script', 100 );
    function wp_change_sticky_header_script() {
       wp_deregister_script( 'avia-sticky-header' );
       wp_enqueue_script( 'avia-sticky-header-child', get_stylesheet_directory_uri().'/js/avia-snippet-sticky-header.js', array('avia-default'), $vn, true);
    }

    As mentioned above, everything works on my end, just not with avia_load_shortcodes. It is not added to the site in any other way or twice in the functions.php …

    Is that a problem?

    In the end I don’t want to interfere with Guenni007’s question at the devs (post-1342985), I just wanted to give a short notice to others having the same problem that the code is not working, but maybe it is just me having this malfunction.

    #1343939

    Hi!

    again here my question to the devs : is it realy necessary to have on menu.css set these rules ( top and position ) for media-query to be !important ?

    Did you test this already? Is it working properly without the !important rule in the following css?

    .responsive #top .av-switch-990.av-submenu-container{top: auto !important; position: relative !important; height:auto; min-height:0; margin-bottom: -1px;}
    

    Cheers!
    Ismael

    #1347600

    Since latest Enfold update all of Guenni007’s files are working fine. With standard child-theme shortcode loading as described in the documentation.


    @Ismael
    : I am testing the files for some weeks, in my opinion everything is working fine without the !important

    #1347653

    Hi,
    Glad Guenni007 & Ismael could help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 23 posts - 1 through 23 (of 23 total)
  • The topic ‘How To Make The SubMenu Sticky On Mobile’ is closed to new replies.