0

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?

0

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...

7
  • 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 :( – Tyler Dahle Sep 26 '17 at 21:31
  • However, it works in my development org. Just not in orgs that I install the package to... – Tyler Dahle Sep 26 '17 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(); – Emmanuel BRUNO Sep 27 '17 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 – Tyler Dahle Sep 27 '17 at 13:29
  • That's weird, did you try to System.debug(PageReference.forResource('SchedulerSitesLogo‌​').getUrl()); in the developer console ? – Emmanuel BRUNO Sep 27 '17 at 19:13

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.