Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. My own menu doesn't change the pages

My own menu doesn't change the pages

Scheduled Pinned Locked Moved General Discussion
menu
9 Posts 2 Posters 1.4k Views
  • 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.
  • ArneRobotA Offline
    ArneRobotA Offline
    ArneRobot
    wrote on last edited by
    #1

    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
    0
    • ArneRobotA Offline
      ArneRobotA Offline
      ArneRobot
      wrote on last edited by
      #2

      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
      0
      • arminunruhA Offline
        arminunruhA Offline
        arminunruh
        Global Moderator
        wrote on last edited by
        #3

        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
        0
        • ArneRobotA Offline
          ArneRobotA Offline
          ArneRobot
          wrote on last edited by
          #4

          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
          0
          • ArneRobotA Offline
            ArneRobotA Offline
            ArneRobot
            wrote on last edited by ArneRobot
            #5

            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
            0
            • arminunruhA Offline
              arminunruhA Offline
              arminunruh
              Global Moderator
              wrote on last edited by
              #6

              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
              0
              • ArneRobotA Offline
                ArneRobotA Offline
                ArneRobot
                wrote on last edited by
                #7

                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
                0
                • arminunruhA Offline
                  arminunruhA Offline
                  arminunruh
                  Global Moderator
                  wrote on last edited by
                  #8

                  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
                  0
                  • arminunruhA Offline
                    arminunruhA Offline
                    arminunruh
                    Global Moderator
                    wrote on last edited by
                    #9

                    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
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    I also code custom websites or custom Lay features.
                    💿 Email me here: 💿
                    info@laytheme.com

                    Before you post:
                    1. When using a WordPress Cache plugin, disable it or clear your cache.
                    2. Update Lay Theme and all Lay Theme Addons
                    3. Disable all Plugins
                    4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

                    This often solves issues you might run into

                    When you post:
                    1. Post a link to where the problem is
                    2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
                    3. If the problem is difficult to explain, post screenshots / link to a video to explain it
                    Online Users
                    A
                    alasdair17
                    Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
                    laytheme.com
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Search