3

For one of the projects out customer want to have a custom header in partner community, but it should show some info based on the user currently logged in. For that I can use VisualForce and inject it with HTML, but the problem is that I don't have the global search box or name drop-down anymore if I use it:

standard community header Standard community header. Global search and name drop-down are clearly visible

custom community header Custom community header. Here I only have the field that I added

Here's the code:

HTML header:

<script>
    var xmlhttp;
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    } else { // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.write(xmlhttp.responseText);
        }
    }
    xmlhttp.open("GET","/myCommunity/MyCommunityHeader",false);
    xmlhttp.send();
</script>

VF page:

<apex:page showHeader="false" sidebar="false" standardStylesheets="false" controller="MyCommunityHeaderController">
    <apex:outputPanel id="MyHeader" layout="block" style="margin:40px;">
        <apex:outputText value="Hello {!userName}!" />
    </apex:outputPanel>
</apex:page>

Apex controller:

public with sharing class MyCommunityHeaderController {

    public String userName { get; set; }

    public MyCommunityHeaderController() {
        userName = UserInfo.getName();
    }
}

So no real rocket science.

VF page and Apex controller are quite basic and they just show the user's name(will add more to show, but that is not relevant to the question).

The HTML page injects this VF page into the header, so that we can use VF in the header(standard we can only use HTML or an image)

So the question is: how do I add/keep the global search and ability to logout/go to setup when I use custom header?

3
  • stupid question: ins't it just the showheader="false" part of you VF page? Aug 3 '15 at 8:08
  • @JurVanOerle nope. If I set it to true I'll get a header in this VF page that is actually this page itself, which has a header that is actually this page itself, which has a header that is actually this page itself... And so on, and so on, and so on... :)
    – Novarg
    Aug 3 '15 at 8:13
  • Hi @Novarg, any luck on this? Still looking for a solution on creating a custom header that keeps the global search + the drop down buttons for my settings and logout
    – sfdx
    Feb 10 '16 at 20:55
2

Isn't it just this:

https://help.salesforce.com/apex/HTViewHelpDoc?id=communities_search_box.htm&language=en_GB

Applied to your MyCommunityHeader page? That's what I've used in the past.

2
  • Thanks for your reply. I've seen it, but the problem is that this only gives the global search, but not that blue bubble with your name in it, so I still can't logout or go to "My Settings"
    – Novarg
    Aug 3 '15 at 8:48
  • Sorry, didn't notice that part of your question. TBH, I think you might have to build the UI parts yourself and just join them up to the relevant links for My Settings and Logout. Again, that's what I've done before, but the customer wanted to to look like it wasn't Salesforce so custom UI was actually a benefit.
    – Aidan
    Aug 3 '15 at 8:53

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.