Home
TeamSite
How to check the value of checkbox when doing templating?
kwoo
How do I check the value of checkbox using iw_if tag when doing presentation templates? I am doing something like this: ]]><iw_if expn="{iw_value name='dcr.NameOfField'/} eq '1'"><iw_then><![CDATA[
Print something
]]></iw_then></iw_if><![CDATA[
Btw, the checkbox item is inside a container tag.
Thanks!
Find more posts tagged with
Comments
mogoo
We've found that you have to treat checkboxes like replicants, even though they're not replicants in your DCT...
in datacapture.cfg....
< item name="CheckboxField">
< checkbox>
< option value="one" label="one" selected="t"/>
< option value="two" label="two" />
< option value="three" label="three" />
< /checkbox>
< /item>
in your tpl...
< iw_iterate list="dcr.CheckboxField" var="format">
< iw_if expr="{iw_value name='format'/} eq 'one'">< iw_then>< ![CDATA[ DOSOMETHING ]]>< /iw_then>< /iw_if>
< /iw_iterate>
--------------------------------------------------------------------------
in your case, because the checkbox item is inside a container tag, I believe the syntax is "container.CheckboxField" instead of "dcr.CheckboxField".
Hope that helps,
maureen
kwoo
How to access checkbox values within container tag?
I have the following code in DCT:
<item name="FieldName">
<checkbox>
<option label="Yes" value="1" />
<option label="No" value="0" />
</checkbox>
</item>
In my TPL, I do something like this:
]]><iw_iterate list="dcr.FieldName" var="temp"><![CDATA[
<br>]]><iw_value name="temp"/><![CDATA[
<br>]]></iw_iterate><![CDATA[
This way works fine. As soon as I added the container tag in DCT to orgranize the fields, I can't access the checkbox values anymore.
DCT with container looks:
<container name="Title" combination="and">
<item name="FieldName">
<checkbox>
<option label="Choice1" value="one" />
<option label="Choice2" value="two" />
</checkbox>
</item>
</container>
TPL with container looks:
]]><iw_iterate list="container.FieldName" var="tempvar"><![CDATA[
<br> ]]><iw_value name="tempvar"/><![CDATA[<br>
]]></iw_iterate><![CDATA[
I have multiple container tags within the DCT. Any ideas what the issue with accessing checkbox values inside container tag? Many thanks!
mogoo
it should be Title.FieldName, not container.FieldName -- sorry for the confusion. I'm pretty sure that'll work.
Adam Stoller
FYI - instead of:
-----------------
<iw_pt name="...">
...
]]><iw_iterate list="container.FieldName" var="tempvar"><![CDATA[
<br> ]]><iw_value name="tempvar"/><![CDATA[<br>
]]></iw_iterate><![CDATA[
...
</iw_pt>
---------------------
As of 5.0.1 - you no longer need to have your PT's be well-formed XML - so you could just do:
<iw_pt name="...."/>
...
<iw_iterate list="container.FieldName" var="tempvar">
<br><iw_value name="tempvar"/><br>
</iw_iterate>
...
---
--fish
(Interwoven, Curriculum Development)
tecthis
Strange, our check box values come through as true or blank. The way we check is basically, if the field exists then its true. The following code works for us.
<iw_if expr="{iw_value name="dcr.fireld"/}">
<iw_then>
Hope this helps,
Alex...
Alexander Correaa
alex_correa@baxter.com
kwoo
Does it mean I can do the following without using CDATA in a TPL:
<img src="<iw_value name='dcr.imagename'/>" width="100" height="100"> in TeamSite 5.5.2?
In the past, I have been writing the following in TPLs:
<img src="]]><iw_value name='dcr.imagename'/><![CDATA[" width="100" height="100">
Thanks for your info.
Adam Stoller
I do not believe you can do:
<img src="<iw_value name='dcr.imagename'/>" with="100" height="100">
I believe you would have to use the *alternate* style:
<img src="{iw_value name='dcr.imagename'/}" with="100" height="100">
Note the use of curly-braces '{}' instead of angle-brackets '<>' surrounding iw_value.
--fish
(Interwoven, Curriculum Development)