[Resolved] reposition generate_insert_into_navigation

Home Forums Support [Resolved] reposition generate_insert_into_navigation

Home Forums Support reposition generate_insert_into_navigation

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1581212
    Michael

    Hello,
    I’m using the following code to insert a “login” link with redirect js to the menu

    add_action( 'generate_inside_navigation','generate_insert_into_navigation' );
    function generate_insert_into_navigation(){
    	if (! is_user_logged_in()) 
    { ?>
    <a href="/login/" onclick="window.location = '/login/?redirect_to='+window.location.href; return false;">Login</a>
    <?php }
    }

    This works fine, but I would like to know if there’s an easy way to
    1. move its position to the end of the menu?
    2. add it to the off-canvas menu?

    Thanks in advance!

    #1581435
    David
    Staff
    Customer Support

    Hi there,

    can you share a link to your site so i can see the layout for positioning it at the end.

    The Off Canvas Panel has two hooks inside it:

    before menu: generate_inside_slideout_navigation
    after menu: generate_after_slideout_navigation

    So you can simply hook your function in there as well.

    #1582696
    Michael

    Thanks, David.
    Here’s the link https://app-5fd0af24c1ac1a221c18b62f.closte.com/
    The first login menu item is added via the hook and I would like to position it after ‘browse’

    But I’m rethinking my approach. Aside from repositioning, I also need it to use the same css for my nav. I’m using the hook only because I need the onclick function to add a redirect to the login URL. Do you recommend a different approach?

    Regards,
    Mike

    #1583383
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Have you considered adding it as a regular menu item? Then you could just give it a class and target the class with some JS instead of writing it inline.

    #1585147
    Michael

    cool. thanks, tom. I got it working now!

    #1586437
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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