You need to sign in to do that
Don't have an account?
Moha
Dynamic reference to Static Resource in Managed Package
Hello i'm developping a managed package, and i would like to know how can the customer change an image or a file which is included in a visualforce page, i know that it's not possible with static ressource since we cannot modify a static ressource with a managed package so any snippet of Code for Help i found this snippet but it's not complet if there is anyone who can help that would be great
public String getLogo() { if (theFormat != null && theFormat.Logo__c != null && theFormat.Logo__c.length() > 0) { List<Document> docs = [ SELECT Name, Id From Document WHERE Name = :theFormat.Logo__c LIMIT 1 ]; if (docs.size() > 0) { Document doc = docs[0]; string imageid = doc.id; imageid = imageid.substring(0,15); return '<img src="/servlet/servlet.FileDownload?file=' + imageid + '"/>'; } } return ''; }
<apex:outputText value="{!Logo}" escape="false" />
URL: www.something.com?banner=/resource/4567/banner.png
on Page
<apex:image URL="{!$CurrentPage.Parameters.banner}" />
Hello, thanks for the reply but i don't get how this is going to help ??? my case is that i have a managed package and when the customers install my package they need to change my logo on site with their own logo and since it's not possible with static ressource how it's going to be possible with ur answer i didn't get it, thanks for the help
thanks,
i don't see how this is possible ??? and my customer should always write code to do that, i need something that allow my customer without code just customising to change the logo, if you have seen the Code Above Using Document Object
public String getLogo() {
String logo='MyLogo';
if (logo.length() > 0) {
List<Document> docs = [ SELECT Name, Id From Document WHERE Name = :logo LIMIT 1 ];
if (docs.size() > 0) {
Document doc = docs[0];
string imageid = doc.id;
imageid = imageid.substring(0,15);
return '<img src="/servlet/servlet.FileDownload?file=' + imageid + '"/>';
}
}
return '';
}
<apex:outputText value="{!Logo}" escape="false" />
but this doesn't retrieve the Image, i guess the error is in the <apex:outputtext> ?
Try this:
Replace the following line
return '<img src="/servlet/servlet.FileDownload?file=' + imageid + '"/>';
with
return '/servlet/servlet.ImageServer?id='+imageid; or
return '/servlet/servlet.FileDownload?file=' + imageid;
Also, replace
<apex:outputText value="{!Logo}" escape="false" />
with
<img src="{!Logo}" />