I am wondering if I can include a SiteHeader visualforce component with my managed package to be used as the header for force.com sites that references a static resource, but not include that static resource in the package?

It is to allow companies to put their own logo there, but if the static resource gets packaged, then that name gets taken, and they can't change the image in the static resource.

And of course, the static resource cannot be deleted before packaging because it is being referenced by the component, and of course I can't try making a static resource without the namespace, because the component has the namespace and it uses that...

Is there anyway I can get the header component packaged, then use a static resource the client makes in their org with their logo? Or is the only way to handle this to simply provide instructions/copy pastable code on how to create the header, then how to create the static resource if they want to use their logo on force.com sites in our package?

1 Answer 1


I would just tell the customers to create a static resource named "CustomerLogo" (or whatever you like) if they want to override yours. Then in the component controller, I would add this getter :

public String customerLogo { 
    get { 
        try {
           return PageReference.forResource('CustomerLogo').getUrl();
        catch (System.InvalidParameterValueException e){
            return null;

That will return the logo url if set, null if the resource is not created.

Then in the ApexPage :

<apex:image id="cusLogo" value="{!customerLogo}"rendered="{!customerLogo!=null}" />
<apex:image id="yourOwnLogo" value="{!$Resource.yourOwnLogo}" rendered="{!customerLogo==null}" />

That will display either your logo, or the customer's if he created the resource.

Did not test it, but I think it'd work...

  • Thank you for the response. Doing exactly what you have posted, I created a static resource named 'SchedulerSitesLogo' and uploaded the image to it. I do 'return PageReference.forResource('SchedulerSitesLogo').getUrl();' and it displays nothing. The apex:image is actually gone from the html of the page because I am assuming it is just returning null instead :( Sep 26, 2017 at 21:31
  • However, it works in my development org. Just not in orgs that I install the package to... Sep 26, 2017 at 21:35
  • Did you create the static resource SchedulerSitesLogo in your dev org and deploy it with the package, or create it after deployment in the destination org ? If you plan to let the customer create his resource himself, you should do the second method. If you plan to create the resource for him and deploy a specific version for him (would be surprising but why not) and so use the first method, then I guess you should use the namespace : PageReference.forResource('YourNamespace__SchedulerSitesLogo').getUrl(); Sep 27, 2017 at 8:23
  • I'm letting them create the resource. I created the static resource with their logo in their sandbox, so not deploying one with my package, and it wasn't picking it up Sep 27, 2017 at 13:29
  • That's weird, did you try to System.debug(PageReference.forResource('SchedulerSitesLogo‌​').getUrl()); in the developer console ? Sep 27, 2017 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .