[SalesForce] Include page dynamically

I have the following code, and I would like to render as PDF:

<apex:page controller="MyController">
    <apex:repeat value="{!pagesToShow}" var="page">     
            <apex:include pageName="{!page}" />
    </apex:repeat>
</apex:page>

templatesToShow is a list in the controller that holds VF pages.

This doesn't works because apex:include is looking the page variable in the controller. But It's not here because it's within the repeat scope.

Any advice to get dynamic page showing?

Best Answer

You can (in a limited fashion) do dynamic includes. The trick is to use the $Page global like this:

<apex:page>
    <apex:include pageName="{!$Page[$CurrentPage.parameters.include1]}" />
</apex:page>

Then direct people to the URL:

/apex/DynamicInclude?include1=ThePage

Is this something you can build upon?

Related Topic