I have a PT in which I am trying to iterate over dcrs I have loaded with iwpt_load_dcr. I have successfully accessed the values inside these dcrs but what I want to do now is make it so that I dont need to hardcode the root-container name since it is variable between several of the dcrs. For example:
<root-container name="networking" location="networking">
<root-container name="telecom" location="telecom">
In the presentation template I use <iw_iterate list='dcr' var='dcrs'> to access the dcrs directly. If I do something like
<iw_iterate list='dcr' var='dcrs'>
<iw_iterate list='dcrs.networking' var='x'>
<iw_value name='x.servicetitle' />
</iw_iterate>
</iw_iterate>
All of the servicetitles for the networking dcrs will be properly displayed. Unfortunately because the root-container names for the different dcrs I've loaded are all different (the field names are all the same, just the root-containers are different) and I don't want to hardcode a root-container name in the PT I have no idea how to access any of the values using variables.
The way it currently works is I store all of the root-container names in a
@sectionlist by grabbing them from the directory paths earlier in the template when I load up the DCRS. Then I strip all the whitespaces and make everything lowercase before storing the values in
@category as follows:
<iw_iterate list="
@sectionlist" var="section">
<iw_perl>
<![CDATA[
if (iwpt_dcr_value('$section') ne "sitemap")
{
my $sectionname = iwpt_dcr_value('$section');
$sectionname =~ s/\s//g;
$sectionname = lc $sectionname;
$sectionname = "dcrs.$sectionname";
push
@category, $sectionname;
}
]]>
</iw_perl>
</iw_iterate>
This code works properly,
@category is full of dcrs.networking, dcrs.telecom as I expected. For the next piece I've tried several different things, one example which I believe is the closest to working is:
<iw_iterate list="
@category" var="outer">
<iw_perl>
<![CDATA[
my $varouter = iwpt_dcr_value('$outer');
iwpt_output("<b>$varouter</b><br />");
]]>
</iw_perl>
<br>
<iw_iterate list='$varouter' var='inner'>
<iw_value name='inner.servicetitle' />
</iw_iterate>
</iw_iterate>
$varouter contains dcrs.networking (etc). In the bottom iterate, I tried it as shown here and I also tried removing the iterate, appending .servicetitle to $varouter in the perl above and just doing <iw_value name='$varouter' />. The closest I can get is having the string dcrs.networking.servicetitle output rather than the value of that. If anyone can help it would be greatly appreciated. Thanks.