As part of an application I am working on, I'm attempting to build a component that can be included many times on a single page with each instance using a different set of parameters. I understand that in the page XML I could just define the component multiple times with the appropriate url as follows:
Web Script Component
Page XMLCode:<webscript> <shortname>Ads</shortname> <description>Component that displays the various Ads on the site.</description> <url>/components/ad/{channel}</url> </webscript>
While this works, these components will change constantly and may even be different depending on the context of the page. To address this, I've created a component that acts a container for other components. Here is the ftl:Code:<page> <id>landing</id> <title>page title</title> <template-instance>landing-template</template-instance> <authentication>none</authentication> <order-id>0</order-id> <components> <component> <region-id>ad</region-id> <url>/components/ad/502</url> </component> <component> <region-id>ad</region-id> <url>/components/ad/501</url> </component> ...
What I'm looking for is a way to dynamically update the template {channel} parameter for the component being rendered based on the loop. So ideally, I would like to be able to do the following:Code:<!-- column --> <#list columnContent.columnComponent as columnComponent> <#switch columnComponent.componentType> <#case "ad"> <!-- ad --> <@region id="column-ad" scope="page" /> <#break> </#switch> </#list>
But this doesn't work. The local "channel" is not assigned in the context. Anyone have any ideas?Code:<!-- column --> <#list columnContent.columnComponent as columnComponent> <#switch columnComponent.componentType> <#case "ad"> <!-- ad --> <#assign channel = columnComponent.channel> <@region id="column-ad" scope="page" /> <#break> </#switch> </#list>
Thanks,
Kevin


Reply With Quote
