Lay Theme Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Search

    My own menu doesn't change the pages

    General Discussion
    menu
    2
    9
    1305
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ArneRobot
      ArneRobot last edited by

      Hello Armin,

      I tailored my own menu on a "Lay"-installation to support a dropdown-sub-menu. I hijacked the original styles and everything worked pretty nice except for one big problem: the menu doesn't navigate to the different pages on the the site! I guess it is some AJAX-problem and I'm missing something. Could you please have a look and help me with that?

      My development site is here: http://laboratorium-haus1.de/wp/

      Thank you and best regards,
      Arne

      1 Reply Last reply Reply Quote 0
      • ArneRobot
        ArneRobot last edited by

        UPDATE:

        I have managed to make the menu actually change my pages.

        This did the trick:

        add_filter( 'nav_menu_link_attributes', 'cfw_add_data_atts_to_nav', 10, 4 );
        function cfw_add_data_atts_to_nav( $atts, $item, $args ) {

        $atts['data-id'] = $item->object_id;
        $atts['data-title'] = $item->title;
        $atts['data-type'] = $item->object;
        return $atts;
        

        }

        But it still doesn't update the current page classes. So still the wrong pages get highlighted when I navigate via the menu. Hmmm…

        1 Reply Last reply Reply Quote 0
        • arminunruh
          arminunruh Global Moderator last edited by

          Hey, yeah u're smart. Your changes will disappear when you update lay theme cause u changed some php code of the theme. :D
          Hm I think you need to use some js to add the class "current-menu-item" to the li's of the submenu points once a new page has loaded.
          Maybe something like this, haven't tested this though:

          <script>
          Frontend.module("GlobalEvents").on('projectpageshown', function(){
          
          var id = jQuery("body").attr('data-id');
          var type = jQuery("body").attr('data-type');
          jQuery(".current-menu-item").removeClass("current-menu-item");
          jQuery('nav a[data-type="'+type+'"][data-id="'+id+'"]').parentNode().addClass("current-menu-item");
          
          });
          </script>
          
          1 Reply Last reply Reply Quote 0
          • ArneRobot
            ArneRobot last edited by

            Armin, I know about the updates. I made most of the changes in a child-theme and will transfer the rest of the edits to my child theme as well. That is a common technique so it should work out alright.

            Thanks for your help – I will test that today.

            1 Reply Last reply Reply Quote 0
            • ArneRobot
              ArneRobot last edited by ArneRobot

              Hello Armin,

              I am working with a friend who us a developer as well but we can't get your code to work. We tried our own but with no real solution:

              <script>
              
              jQuery("nav li a").on('click', function(){
              
              var id = jQuery("body").attr('data-id');
              var type = jQuery("body").attr('data-type');
              console.log(id);
              jQuery(".current-menu-item").removeClass("current-menu-item");
              jQuery('nav a[data-type="'+type+'"][data-id="'+id+'"]').parent().addClass("current-menu-item");
              	
              });
              
              </script>
              

              The result can be seen here: http://laboratorium-haus1.de/wp

              Any idea how to modify the script/your script to make the changes of the highlights possible?

              Thank you!

              1 Reply Last reply Reply Quote 0
              • arminunruh
                arminunruh Global Moderator last edited by

                Ah Ok, I thought it wasn't possible to make a child theme with lay theme.
                Yeah about your code. Maybe try a timeout. Put all of that code "var id = jQuery("body").attr('data-id');
                var type = jQuery("body").attr('data-type');
                console.log(id);
                jQuery(".current-menu-item").removeClass("current-menu-item");
                jQuery('nav a[data-type="'+type+'"][data-id="'+id+'"]').parent().addClass("current-menu-item");" in a timeout.

                1 Reply Last reply Reply Quote 0
                • ArneRobot
                  ArneRobot last edited by

                  Thank you! I will investigate this if necessary.

                  As for now we found a work-around: we use "category" for the artists. That way the menu works almost perfectly. See here: http://laboratorium-haus1.de/wp/

                  The sole open question/problem now is how to highlight the individual artists in their different projects as there is no hierachy that one could style when loading the pages through the menu. Any idea is appreciated – if there is no solution we'll just go without that highlight…

                  And yes: child themes are possible. I didn't manage to change everything by my own files since some files are loaded after the child theme files and will make custom changes go away but well…

                  Cheers, Arne

                  1 Reply Last reply Reply Quote 0
                  • arminunruh
                    arminunruh Global Moderator last edited by

                    Hmm hmm, I would have to take a close look and like code that for you so it would work. But I don't really have time for that right now cause I got some deadlines ahead of me for some freelance work.

                    I think its pretty amazing how much you have customized lay theme!

                    1 Reply Last reply Reply Quote 0
                    • arminunruh
                      arminunruh Global Moderator last edited by

                      Hey, maybe this helps. Since the update 1.056 today, there are better javascript events that you can use:

                      http://laytheme.com/how-to-use.html#custom-javascript

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Post a link to where the problem is if possible, please <3
                      I don't answer or check forum DMs, please just post on the forum.
                      Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com

                      Before you post:

                      Use the Search Feature. Maybe there is already a solution to your issue.

                      1. Update Lay Theme and all Lay Theme Addons
                      2. Disable all Plugins
                      3. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code ", click "Save Changes"
                      4. When using a WordPress Cache plugin, disable it or clear your cache. Now see if your problem solved itself.
                      Go here, see if your problem is listed here:
                      Troubleshooting

                      When you post:
                      1. Post a link to where the problem is
                      2. If the problem is difficult to explain, post screenshots / link to a video to explain it

                      Thanks!

                      Online Users

                      M
                      B

                      Recent Topics

                      • Search as icon instead of text?

                      • FILTER Categories showing all projects

                      • H

                        Vimeo embed with autoplay and loop is really slow...help!

                      • A

                        website not loading on iphone safari

                      laytheme.com