5

Documentation says I can choose an HTML file for header image in Customer Portal. Searching on the internet is showing that people have uploaded the image on Documents, and referring to the ID of this Document image in their HTML file. This means that after deployment, I will have to manually change the ID in my HTML file. I want the solution to be sustainable, i.e., no maintenance should be needed after deployment. Is there a way to add an image banner without using ID?

Can you provide me the snippet of HTML code?

Edit: In case I use Header Logo field in Customer Portal, the image will get scaled down to 300px width, like the screenshot below. Hence I can't use this approach if I have to add a Customer Portal image banner covering full width of the page, just above the tabs. Also, in case of using Logo field, the image will have to be less than 20 KiB.

enter image description here

5
  • I am not sure why you want to add as html .Please see my answer .You can change the header logo as needed . Commented Feb 12, 2013 at 8:37
  • @MohithKumar, I can't use logo field, because image logos are getting scaled down to 300px width. Hence I can't use this approach if I have to add a Customer Portal image banner covering full width of the page, just above the tabs. Also, in case of using Logo field, the image will have to be less than 20 KiB. Commented Feb 12, 2013 at 8:48
  • .I see .Upvoting the question and deleted my answer .Also mention these points in question so that the question is crystal clear!Cheers! Commented Feb 12, 2013 at 8:49
  • @MohithKumar, thank you for your suggestion. I have mentioned these points in my question and added a screenshot of why I cannot use header logo field. Commented Feb 12, 2013 at 8:54
  • Excellent!This will give better understanding and also ensure you will get proper response and suggestions Commented Feb 12, 2013 at 9:00

2 Answers 2

4

This will smell horrendous but I'm guessing you want HTML in the portal header for good reason ;-)

Upload it as a Static Resource and use JavaScript UserContext.siteUrlPrefix to resolve the path:

<script type="text/javascript">
  document.write(
    "<img " +
      "src='" + UserContext.siteUrlPrefix + "/resource/yourImagePng'" +
    "/>"
  );
</script>
5
  • Nope, not working. I don't think that UserContext can work in non-VF HTML pages. Commented Feb 12, 2013 at 9:05
  • It'll only work in a Force.com Site or Customer Portal via your HTML header. If you inspect the DOM, what is the URL that ends up in your img tag? Commented Feb 12, 2013 at 9:42
  • Hey @BarneyRubble, that's JavaScript, not Visualforce - please try again carefully. Commented Feb 12, 2013 at 10:27
  • 2
    Thank you for stubbornly sticking around! It works perfectly. Since this functionality is undocumented and in case Salesforce changes the URL for accessing Static Resources later, do you see any issues in the future? Commented Feb 12, 2013 at 10:40
  • :-) maybe take a look at Chatter Communities which offers better customization options Commented Feb 12, 2013 at 12:28
0

In my case it also worked without the siteUrl prefix (and adherent javascript). So I just put:

<link href="/resource/PartnerPortalAssets/style.css" rel="stylesheet">

for my css file

which would translate to:

<img src="/resource/yourImagePng" />

for your image

2
  • nice - simpler is always better, just note it won't work on any Site with a Name... Commented Nov 28, 2013 at 16:57
  • good point! Also on Communities this might not work. Commented Nov 29, 2013 at 18:23

You must log in to answer this question.

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