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
daveespodaveespo 

Managed package VF page referencing $Site.Template (stock site template)

I am having a problem with the <apex:composition> tag. I have created my Sites application in my development org and packaged the VF pages and Controller into a managed package.

 

When I install the package into the destination org, the only Site Template I'm able to use is the site template that I packaged with my app. I want to allow the user to create their own Site Template (unmanaged, in their org) and set this page as the Site Template.

 

To be perfectly clear, this is what I'm doing:

 

<apex:page>
    <apex:composition template="{!$Site.Template}">
        <apex:define name="body">

            Blah blah blah

         </apex:define>
    </apex:composition>
</apex:page>

 

And the template I package with my app:

 

 <apex:page >
        <div class="content"><apex:insert name="body" /></div>
        <div class="footer">
            <apex:outputText value="Copyright 2009"/>

         </div>
</apex:page>

 

When I deploy my package, if i configure my Site to use the template that I've packaged, everything works fine. But the moment I change the Site Template to point at a different template that didn't come with my package, I get a 404/File Not Found

 

 

Best Answer chosen by Admin (Salesforce Developers) 
BulentBulent

We might have a name space issue with the $Site.Template expression. We need to test.

Mean time take a look at this related posting and use the following as a workaround for now

 

<apex:composition template="namespace__TemplatePageName">

 

 

 

All Answers

Ron WildRon Wild

I'm seeing the same problem.   The code in the user template is shown but the content in the packaged page has been replaced with the 'page not found' message.

 

I've also tried updating the API version on the pages and controllers to v.16 to no avail.

 

 

BulentBulent

We might have a name space issue with the $Site.Template expression. We need to test.

Mean time take a look at this related posting and use the following as a workaround for now

 

<apex:composition template="namespace__TemplatePageName">

 

 

 

This was selected as the best answer
Ron WildRon Wild

Bulent,

 

Has this bug been fixed yet?   I still get an error when attempting to use $Site.Template in a packaged Visualforce page in my test account.

 

Without access to this global, it is difficult to distribute visualforce pages in a managed package for end users to include in their own Sites implementations.

 

Regards,

Ron

BulentBulent

Ron,

 

Please email me the case number, and let me know if you haven't filed a case yet.

 

Ron WildRon Wild

Bulent,

 

We still haven't heard anything from you guys on this.  As it stands right now, we cannot publish managed visualforce pages that use the <apex:composition> tag and reference a template outside of the managed package.

 

$Sites.Template doesn't work, and neither does <apex:composition template="{!templateName}" >

 

... where templateName is a string representation of the template the end user wants to apply to the page. 

 

In the latter case, the platform pre-pends the name with the package prefix.

 

We're chomping at the bit to release several applications but can't proceed - any suggestions on how to get around the problem?

 

Thanks,

Ron

 

BulentBulent

Ron,

 

the bug is associated with your case. Let's go through the support process on this. 

Ron WildRon Wild

For those of you following this thread, a fix for this problem was released in Spring '10.  You can now include $Site.Template in a managed package visualforce page and apply an unmanaged template file to the page after installation.

 

There appears to be an issue with including components in the unmanaged template in this scenario but hopefully that will be fixed soon.

 

Cheers,

Ron

 

jpcubojpcubo

Can you show me an example on how to apply an unmanaged template in a managed package?

zmcelrath87zmcelrath87

I am having this same issue --- it doesn't appear to have been fixed. 

 

My situation is exactly the one that daveespo describes, but I don't get a 404/File-Not-Found error --- I just see the content of my template, but all of the insert/define sections are blank --- absolutely nothing gets inserted into them. As soon as I switch back to using a template included in my Managed Package, everything works fine. But unmanaged templates don't seem to work at all.

 

Regards,

 

Zach McElrath

Skoodat LLC

Devendra@SFDCDevendra@SFDC

Hi All,

 

I am also facing the same issue.

 

If we provide template which is part of managed package then it works.

 

If template assigned is not a part of managed package then it gives problem.

 

How to resolve this issue?

 

Thanks,

Devendra