Appirio's Tech Blog

Friday, July 25, 2008

Salesforce Customer Portal CSS Modifications

Michael
McLaughlin


The Problem: How do I modify my Customer Portal implementation to match my public facing website?


The Salesforce Customer Portal is a great extension to Salesforce.com that allows companies to open up certain areas of their Salesforce organization to designated customer users for self-servicing their accounts. The Portal lets customers make account changes, log and view status on a case and provides answers to common customer questions...all without involving a support representative and inherent response delay.

Out of the box, the customer portal retains the standard Salesforce.com look and feel we have all grown accustomed to. End user of the portal (the customer's customers) however, will most likely be unfamiliar with this user interface. In addition, since most Customer Portal implementations hang off of the main website of a customer, there could be confusion for end users if they encounter the standard salesforce.com look and feel.

The Solution: Customer Portal CSS Mods

One solution to this problem is to format salesforce.com Customer Portal to match the style of organization's website. This gives the customer's end user the impression that he is still on the organization's site.

Customer Portal allows minimal customization of fonts and colors through a simple administration interface. This also allows you to supply a custom header and footer. In order to do more than this and complete the visual transformation of your Customer Portal implementation you can use Cascading Style Sheets (CSS).

Salesforce does not produce documentation explaining what CSS classes define which Customer Portal screen elements. This allows them to change these style elements in future releases. As a result, unlike supported salesforce.com customizations, you may need to verify your changes still work with future salesforce.com releases. In other words, be careful with the below :-)

You need to use a tool to help you get under the covers to see the interaction of CSS with what the users sees. Users of Mozilla Firefox have access to an excellent free add-on called Firebug. Firebug allows you to "inspect" the content and structure of any web page. Turn Firebug on and navigate to the pages of your Customer Portal implementation. Hover over the screen elements you wish to modify such as table headers, background images, etc. Take note of the CSS classes Firebug says are responsible for the elements' formatting.

Now that you know what out of the box Customer Portal styles are driving the interface elements you wish to change, you can override them using your own style definitions. You must use the same style class names so your browser will use your style definition and not the default one. Do this by:
  • Modifying the style to your liking in CSS syntax
  • Save your changes to a CSS file you store in Static Resources or Documents
  • Reference your CSS file in the Customer Portal header HTML (accessible in the Customer Portal Administration panel) using a <link> tag
    • OR, if your changes are small, simply use a <style> tag and insert your styles as HTML directly into the Customer Portal header
  • View the resulting changes in Customer Portal and tweak as necessary
  • Use Firebug to hover over your screen elements to see if your styles are being properly used
Further reading: Example of the solution in action:
<style type=text/css>
/* Redefining this style for Customer Portal to make the font smaller */
body {
font-size:9pt;
}

/* Redefining this style for Customer Portal to make the listHeader an image */
.listHeader {background-image: url(/dimg/portalTabRight96999C96999C.gif);}

/* Redefining to make sidebar an image. Kept its present color and font definitions. */
.sidebarModuleHeader,
.nestedModule .sidebarModuleHeader {
background-image: url(/dimg/portalTabRight96999C96999C.gif);
color: #505154;
font-family: Arial, Helvetica, sans-serif;
}
...

Screenshot of Firebug inspecting Customer Portal's style elements:

12 comments:

  1. Good Post, thank you! It helped me to get rid of a left side bar in Customer Portal because it was the only way to do it.

    ReplyDelete
  2. How do you reference the CSS? Anything that goes to the Customer Portal header is included inside the body tag, which means link tag won't work. Thanks.

    ReplyDelete
  3. Hello...the LINK tag for the CSS *can* exist in the BODY...it does not need to be in the HEADER for the styles to take effect.

    ReplyDelete
  4. I'm hoping you can help....

    I created an html file for a custom header with the following content:
    *div* this is the header */div*

    When I log into the portal I see the following at the top of *div*
    this is the header
    */div*

    salesforce.com is not interpreting my file correctly... any ideas?

    I'm using * instead of <> because the website does not support the div tag.

    Thank you,
    Michael

    ReplyDelete
  5. Hi Michael,

    Nice post ! I am learning about customer Portals.

    Thanks,
    Mayank

    ReplyDelete
  6. Can you please post more about overriding customer portal styles and customizing it. I have searching for quite some time for a method to do this. Thanks.

    ReplyDelete
  7. is this still working? I tried with link and sytle and appears both are not working.
    Either I am doing wrong or sfdc might be preventing changes

    ReplyDelete
    Replies
    1. In the 4 years since I wrote this, the format of Portal pages has likely changed. You should still be able to override CSS though...

      Delete
  8. The header file? Jeez....I sure as hell wouldn't have guessed. This is exactly what I was looking for...still works even now.

    Thanks!

    ReplyDelete
  9. How I can link to static resource from html? Can someone post a example?

    ReplyDelete
  10. Question: is there a way to dynamically (or pseudo-dynamically) hide the sidebar for the customer portal? I am able insert a css script into the header page to hide the sidebar, but this hides it for all pages. The problem I am facing is that we want to expose the sidebar for the Home tab, but hide it for any other page. The reason being is that displaying the sidebar causes users to have to scroll left/right which is a big no-no for user experience. Is there some sort of jquery magic that can know if we're on the Home tab or is there some way to only display the sidebar when we're on the Home tab? Remember- this is customer portal users, they can't "minimize" the sidebar.

    ReplyDelete
    Replies
    1. I don't think you can dynamically show it or not. The showSidebar property in the apex:page tag is set at design time, not run time.

      Delete

 
2006-2012 Appirio Inc. All rights reserved.
Appirio.com | Support | Resource Center | Contact | Careers | Privacy Policy