Forum Discussion
Hi Scott,
Sorry for the late follow up. I was forwarded to your post by someone else that had the same question. I figured I'd reply here for the benefit of others.
If you’re adding the component to a page via the page editor in Studio, then I believe you’re fairly restricted in what types of values you can use… pretty much just strings as you discovered.
If you’re adding the component to another component via the <@component> macro, then you have a bit more flexibility. With the macro, you can pass other types and objects as well. For example:
<#assign community=rest("/").community />
<@component id="paramtest" param=community />
Then in your paramtest component, you could do something like:
${env.context.component.getParameter('param').id}
to give you the id of the community.
Here's a better example more a long the lines of what you were talking about. This example shows passing some threads:
<#assign threads=rest("/threads/recent").threads />
<@component id="paramtest" param=threads />
Then in your paramtest component:
<#assign threads=env.context.component.getParameter('param') />
<#list threads.thread as thread>
${thread.messages.topic.subject}<br/>
</#list>
Hey Adam,
do you know, if it is possible to pass a boolean as a parameter? It tried it, but it is not working, so I'm currently passing a "true" or "false" as a string.
Thanks
Nikolay
- luk10 years agoBoss
KPNOnline i had some success with using JSON to transport data, for example like this
<@component id="componentid" data='{"key": "value"}' />
you have to convert this JSON string back to a hash inside the component, this can be done with the ?eval FreeMarker Built-In.Sign in to react to this post - Inactive User9 years agoNot applicableAdamN Any feedback on this?Sign in to react to this post