Find your content:

Search form

You are here

Branded Visualforce Page

 
Share

I am stuck with one scenario here,

I have implemented one Visualforce page, which will be part of a Managed Package and will be represented on a Force.com website.

As this package can be used by multiple organizations. I would like this page would have the branding (css, logo, header, footer etc.) as per the organization.

The question arises here, how we can make these css, logo, header, footer dynamic, so that whichever organization uses this package can do their branding customization, even though this page is part of a managed package?

What do you all suggest here?


Attribution to: Devendra

Possible Suggestion/Solution #1

Great question (take 2:)

As jordan pointed out, the static resource of a managed package is not modifiable, which prevents modification after deployment.

Another possibility is to store your images as documents that can be referenced programmatically. Here's a reference to Sean Devine - referencing superfell's blog ;) This shows how to upload images from an external source, but should be instructive in terms of how to save an image as a document.

Unfortunately, if the static resource was modifiable - you could do this without any coding. But with some additional programming you could create an "image manager" Visualforce page that could allow the user to load images from their local to their org with your managed package installed. You can use the following to load the image from your Visualforce page:

<apex:inputFile value="{!file}" filename="{!name}"/>

In order to render your documents as images, you can include something like this in your controller:

public String imageURL
{
   get
   {
      String retVal;
      Document doc = [SELECT Id FROM Document WHERE Name = :nameString LIMIT 1];
      String imageId = doc.Id;
      imageId = imageId.substring(0, 15);
      retVal = '/servlet/servlet.FileDownload?file=' + imageId;
      return retVal;
   }
   private set;
}

and then reference it within Visualforce like this:

<apex:image url="{!imageURL}" width="XXX" height="YYY"/>

(thanks, Ron Hess for the great example I modeled this after)

So, I hope that helps :)


Attribution to: Adam

Possible Suggestion/Solution #2

I agree with Adam about using static resources.

However, since you can't override static resource files that are part of managed packages your going to have to request that your individual installed organizations uploaded their own static resource files following a careful naming consideration.

Also dereferencing a non-existant static-resource url in a vf page like Adam suggested will cause the page not to compile:

<apex:image value="{!URLFOR($Resource.YourZipFileHere, 'header.png')}"/>

So your going to have to include placeholders, my only question is how your going to a compile a page to override this items in the installed org since you'll need those URLs but you also want them to change afterward. Someone might have a clever suggestion...but I don't think it's possible?


Attribution to: jordan.baucke

Possible Suggestion/Solution #3

Thank you all :) and Sorry for the late reply.

To resolve this issue,

We are using <apex:composition>, <apex:define> and <apex:insert> tags.

Create a VF page which will be part of manage package.

<apex:page>
<apex:composition template="{!$Site.Template}">
    <apex:define name="DemoContent">
        Site content Goes here      
    </apex:define>
</apex:composition>
</apex:page>

In subscriber org, we are going to create Site Template Page. This page will contain the branding of subscriber organization.

Template page:

<apex:page>
    <!-- Add Logo with Header, Menus etc -->
    <apex:insert name="DemoContent" />
    <!-- As above line will containt page from managed package surrounded by subscribers branding-->
    <!-- Add Footer -->

</apex:page>

Add this template page on Site Template Attribute.

The significan work is to create Template page for every subscriber. As this template is created in Subscribers org, the static resources will not create problem.

BY this way, we are handling the Branding.

What do you all suggest?


Attribution to: Devendra

Possible Suggestion/Solution #4

Use of in managed package gives a problem (Provided template is not a part of manage package). If template page is part of managed package then it works.

I have also gone through some of the developer post. They also have faced the same issue.

http://boards.developerforce.com/t5/Force-com-Sites/Managed-package-VF-page-referencing-Site-Template-stock-site/td-p/132151

http://boards.developerforce.com/t5/Force-com-Sites/Developer-Guide-Sites-example-Authorization-Required-issue/m-p/125879#M452

http://boards.developerforce.com/t5/Force-com-Sites/Problem-using-site-templates/td-p/192595

We want to use different template page, not the page from package.

Is this a bug? Do you have any idea about this issue?


Attribution to: Devendra
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/616

My Block Status

My Block Content