Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Help! on nested replicant issue
shyamreb
I'm trying to access items in a nested loop using the <replicant> tag in the datacapture.cfg file, and the <iw_iterate> tag in the style.tpl file. There are two levels of replicants -- I'm able to access first-level items, but unable to access the items at the second level.
Here's the code from my datacapture.cfg file:
<!-- Style information -->
<item name="Style Collection">
<label>Custom style data collection</label>
<replicant min="1" max="100" default="1">
<item name="Style HTML Tag Override Indicator">
<label>Style HTML tag override (Y/N):</label>
<description>Determine if the style is an HTML override style</description>
<radio required="t">
<option value="Y" label="Yes"/>
<option value="N" label="No" selected="t"/>
</radio>
</item>
<item name="Style Name">
<label>Style name:</label>
<description>Custom style name</description>
<text required="t" size="70" maxlength="105"/>
</item>
<item name="Style Attribute Collection">
<label>Custom style attribute data collection</label>
<replicant min="1" max="50" default="1">
<item name="Style Attribute Name">
<label>Style attribute name:</label>
<description>Custom style attribute name</description>
<text required="t" size="70" maxlength="105"/>
</item>
<item name="Style Attribute Value">
<label>Style attribute value:</label>
<description>Custom style attribute value</description>
<text required="t" size="70" maxlength="105"/>
</item>
</replicant>
</item>
</replicant>
</item>
Here's the code from my style.tpl file:
<!-- Loop through style collection to get custom styles -->
<iw_iterate var='$CustomStyle' list='dcr.Style Collection' iteration='$CustomStyleCounter'>
<iw_perl>
<![CDATA[
# Initialize variables
$StyleHTMLTagOverrideIndicator = iwpt_dcr_value('$CustomStyle.Style HTML Tag Override Indicator');
$StyleName = iwpt_dcr_value('$CustomStyle.Style Name');
# Remove spaces from style name
$StyleName =~ s/ //g;
# Begin style entry
if ($StyleHTMLTagOverrideIndicator == "N") {
print CommonStyleFile "." . $SiteID . $StyleName . "\n{\n";
}
else {
print CommonStyleFile $StyleName . "\n{\n";
}
]]>
</iw_perl>
<iw_iterate var='$CustomStyleAttribute' list='$CustomStyle.Style Attribute Collection' iteration='$CustomStyleAttributeCounter'>
<iw_perl>
<![CDATA[
# Initialize variables
$StyleAttributeName = iwpt_dcr_value('$CustomStyleAttribute.Style Attribute Name');
$StyleAttributeValue = iwpt_dcr_value('$CustomStyleAttribute.Style Attribute Value');
# Remove spaces and colon characters from style attribute name
$StyleAttributeName =~ s/ //g;
$StyleAttributeName =~ s/://g;
# Continue style entry
print CommonStyleFile "\t" . $StyleAttributeName . ": " . $StyleAttributeValue . "\n";
]]>
</iw_perl>
</iw_iterate>
<iw_perl>
<![CDATA[
# Complete style entry
print CommonStyleFile "}\n";
]]>
</iw_perl>
</iw_iterate>
Find more posts tagged with
Comments
Dwayne
I don't generally use the
$
on my
<iw_iterate>
variables. I'd change your tpl around like this:
<!-- Loop through style collection to get custom styles -->
--
Current project: TS 5.5.2/6.1 W2K
shyamreb
Dwayne,
Thank you so much!!! Removing the "$" from the list variable name worked!!!
---Shyam.
Adam Stoller
A couple of nits - not confined to this one posting - but as I see it come up many times I figured I'd throw it here:
When designing your DCTs - use simplfied names for the items and use labels for the descriptive names you want to show in the form. For example, instead of:
<item name="Style HTML Tag Override Indicator">
...
</item>
try:
<item name="html_override">
<label>Style HTML Tag Override Indicator</label>
...
</item>
Then your PT code is a lot easier to write (IMO), manipulate with things like XSLT, and easier to fit within 80-character columns (which then makes it much easier to read if you ever print it out):
my $html_override = iwpt_dcr_value('CustomStyle.html_override');
Food for thought anyway.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com