We've got a managed app that includes custom Visualforce pages that are exposed via a Force.com Site. We're working on a new version of this Site, that is basically a single page app running within a Visualforce page. So, basically, in order to switch between the old version of the Site and the new version of the Site, I just change the "Active Site Home Page" for the Site. However, there is some back-end business logic that I want to enable when I know that the new Site is active (namely, configuration pages for the new Site). I want to be able to enable this business logic when I detect that the Active Site Home Page is my new Visualforce page, and not the old one. I see there is a queryable SObject called Site, but there is no field on it that records the Active Site Home Page setting. Does anyone know if there is a way to determine which page is being used as the Active Site Home Page from Apex code?
1 Answer
In your particular case, you don't need actually to determine the active site home page (since this is not possible in the current release). Instead, you can have some indicator inside the Visualforce Component like this:
<apex:component >
<apex:attribute name="IsNew" description="Defines if the site is new" type="Boolean" required="true"/>
{!isNew}
</apex:component>
Then on the new Visualforce page you could use the following code
<apex:page>
<c:Detect IsNew="true"/>
</apex:page>
while on the old Visualforce page you could use the following code
<apex:page controller="CPC">
<c:Detect IsNew="false"/>
</apex:page>
In such a way you could distinguish in Apex Code, for example, in the code of controller for the Visualforce component Detect
, which page is used on the site.