I have been asked to hide tome tabs from navigation bar on Partner Community when the logged user is Community User.

What have investigated so far:

Create a custom theme and replace the the layout in community. This takes me to build this logic:

Lightning Component controller to retrieve the element that has the index of the tab item in this case the tag is this:

<a class="slds-navigation-list--vertical__action slds-text-link--reset" data-menu-item-id="1" href="javascript:void(0);" data-aura-rendered-by="6:51;a">Employers</a>

I'm trying to retrieve the element this way

doInit : function(component, event, helper) {
    var x = document.getElementsByTagName("a");
    // Returns a collection

    var y = document.querySelectorAll("li a[data-menu-item-id=\"0\"]"); 
    // I'm not sure what does this return

    document.getElementsByTagName("a")[0].setAttribute("ddisplay", none); 

    // Get the user id, I can work with and an Apex method to get
    // the Profile Name
    component.set("v.userId", $A.get('$SObjectType.CurrentUser.Id'));


To setAttribute("display",none);

I don't now what else to do, I looked for a setting to do this but nothing, also how much effort can this take to get it properly done?

  • Its not recommended to use document methods in your lightning component as you are doing. you can refer to Using JavaScript from the developer documentation – glls Apr 6 at 12:51

It looks like you could make your life easier by using a page variation and simply use a different header component based on that.

  • I have tried what you say in every way as much as I can but I still can't manage to change the navigation bar according to the user's profile. I'm using Partner Central template if it help to troubleshoot my issue. I would appreciate a lot if can give me more details about how to please, my brain is about to explode. Thanks a lot in advance. – AjFmO Apr 7 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.