none
Remove "current site" from top navigation bar with javascript RRS feed

  • Question

  • Hi,

    I would like to know if there is a way to remove the "current site" from the top navigation bar with javascript ( No master page modification). The "current site" appears with the publishing infrastructure feature only.

    I would like to remove it from the "Top navigation bar object" and not only hide it with css.

    Problem is that when I loop in the top navigation bar object, I see all nodes except this one.

    Any idea ?

    Thank you.

    Alex

    Thursday, March 16, 2017 9:21 PM

All replies

  • Hi Alex,

    Seems that this node is not managed by the global navigation or top navigation object, thus, it is not supported to be deleted programmatically.

    A quick workaround is applying CSS to hide it, though it might not be your desired solution.

    Best regards,

    Patrick

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Proposed as answer by romeo donca Monday, March 20, 2017 10:43 AM
    Saturday, March 18, 2017 6:34 AM
    Moderator
  • Hi Patrick,

    I want to create a global navigation for each site collection of my farm ( we don't use subsite ). I use the termstore for this but the metadata managed navigation is limited to only one site collection. To work around this limitation, I create my global navigation with javascript and the termstore manually. This allow me to modify the global navigation of each site collection with one entry point : the termstore.

    Problem is when I activate the publishing feature on a site, it creates a "Home link" node in the global navigation bar and this node override the node in my custom global navigation bar if they have the same URL.

    For example, I have a node intranet in my custom global navigation. If I activate the publishing feature on intranet site, the node intranet in my custom global navigation will not appear because it has the same URL that the node created when publishing feature is activated. In this case  it's not really a problem because Intranet has no sublink, but if a "child node" of my custom global navigation has the same URL than the "home link" of publishing feature, it removes my child node from dropdown menu and put it at the "home link" position.

    I haven't find a way to delete this node with javascript, maybe it's not possible. And the CSS doesn't solve this problem of override. 

    Any idea ?

    Thank you.

    Alex.


    • Edited by AlexDev62 Monday, March 20, 2017 9:20 AM
    Saturday, March 18, 2017 12:34 PM
  • Hi Alex,

    How about removing the whole HTML source code of the links generated by the publishing feature when page loaded? Then build your custom navigation bar using JavaScript from scratch.

    By doing this, the OOTB “Home link” won’t collide with your customization.

    Best regards,

    Patrick

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, March 20, 2017 9:51 AM
    Moderator
  • Hi,

    Problem is that this node is created at every page refresh, I create the global navigation for all site collection remotely on demand ( I have a site collection to do it ), not at every page refresh.

    I think the only way is to modify the master page but I don't want to, I will accept this problem and avoid to activate the publishing feature.

    Thank you.

    Alex

    Monday, March 20, 2017 10:12 AM
  • Hi

     I recommend you Patrick_Liang solution

    Let us know if you need more details


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    Monday, March 20, 2017 10:44 AM
  • Hi,

    In this case every time a user will connect to a sharepoint site, the javascript has to delete the "current navigation" node and create the custom navigation, it's heavy. With my solution, I create the navigation from a dedicated SharePoint site for each site collection, I haven't to deploy the javascript on each site collection. I execute it one time to create navigation for every site collection. Problem is this "current navigation" node, but I think there is no good way to deal with it.

    Thank you.

    Alex

    Tuesday, March 21, 2017 7:50 PM