function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DianeMDianeM 

Overriding Visualforce pages in a managed package

I have a managed package with a number of Visualforce pages.  These pages are intended as a default pages.  Experience tells us that customers who install this managed package are going to want their own version of these pages - they will want to change logos and layouts.  I have not been able to find any suggestions as to how this can be done.  I suspect I may have to change my packaging strategy but I don't know.

 

Does anyone have suggestions about how this can be accomplished.

 

Thanks,

 

Diane 

Best Answer chosen by Admin (Salesforce Developers) 
Andy Freeston_LarterAndy Freeston_Larter

I have deployed a solution that I think solves your problem.

 

My app ships with a zip resource that we allow the user to override. A custom setting holds the name of the resource and this can be configured by the customer using a visualforce page in our package.

 

When we link to the overridable resource, we lookup the name using a static Apex method. If the custom setting does not exist, we use the default resource name otherwise we use the customer set name.

 

The only problem with this method is that the customer's resource is held on a different domain, as packaged resources live in a sub-domain (named after your namespace). I have not found a standard way of getting the domain name so I am using this code:

 

private static String FetchZipName() { // Look-up the zip file name setting SalesMethods__MSOMasterSettings__c[] setting = [SELECT SalesMethods__HelpZipStaticResourceName__c FROM SalesMethods__MSOMasterSettings__c]; // If not set, use the generic file from the package if ( setting.size()!=1 || null==setting[0].SalesMethods__HelpZipStaticResourceName__c || setting[0].SalesMethods__HelpZipStaticResourceName__c.length()==0 ) return '/resource/SalesMethods__MSOHelpGuideSheetsZip'; // Build a full URL, minus the namespace (as the resource will be hosted by the customer) String strHost = ApexPages.currentPage().getHeaders().get('Host'); Integer found = strHost.indexOf( 'salesmethods.' ); if ( -1 != found ) strHost = strHost.substring(0, found) + strHost.substring(found+13); return 'https://' + strHost + '/resource/' + setting[0].SalesMethods__HelpZipStaticResourceName__c; }

 

All Answers

Andy Freeston_LarterAndy Freeston_Larter

I have deployed a solution that I think solves your problem.

 

My app ships with a zip resource that we allow the user to override. A custom setting holds the name of the resource and this can be configured by the customer using a visualforce page in our package.

 

When we link to the overridable resource, we lookup the name using a static Apex method. If the custom setting does not exist, we use the default resource name otherwise we use the customer set name.

 

The only problem with this method is that the customer's resource is held on a different domain, as packaged resources live in a sub-domain (named after your namespace). I have not found a standard way of getting the domain name so I am using this code:

 

private static String FetchZipName() { // Look-up the zip file name setting SalesMethods__MSOMasterSettings__c[] setting = [SELECT SalesMethods__HelpZipStaticResourceName__c FROM SalesMethods__MSOMasterSettings__c]; // If not set, use the generic file from the package if ( setting.size()!=1 || null==setting[0].SalesMethods__HelpZipStaticResourceName__c || setting[0].SalesMethods__HelpZipStaticResourceName__c.length()==0 ) return '/resource/SalesMethods__MSOHelpGuideSheetsZip'; // Build a full URL, minus the namespace (as the resource will be hosted by the customer) String strHost = ApexPages.currentPage().getHeaders().get('Host'); Integer found = strHost.indexOf( 'salesmethods.' ); if ( -1 != found ) strHost = strHost.substring(0, found) + strHost.substring(found+13); return 'https://' + strHost + '/resource/' + setting[0].SalesMethods__HelpZipStaticResourceName__c; }

 

This was selected as the best answer
DianeMDianeM
Thanks Andy, this looks like a good solution.