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)
iw_if, then with iw_iterate
JackB
We're on TS 6.0 still.
See any issues with this string of code in a .tpl I'm working on?
<iw_if expn='{iw_value name="dcr.reminder"/} ne "" '>
<iw_then>
<p class="sidelinksTitle">Reminders:</p><br />
<ul>
<iw_iterate var='x' list='dcr.reminder'>
<li class="sidelinks"><a href="/html/Intr@Post/ste_ho.shtml#<iw_value name='x.Anchor'/>" class="sidelinks"><iw_value name='x.Heading'/></a></li><br /><br />
</iw_iterate>
</ul>
<br /> <hr width="165" noshade="noshade" class="sidelinkshr" />
</iw_then>
</iw_if>
Data has been filled in the DCR for these fields, yet the output file doesn't generate the "then" results. It thinks there's nothing there.
I've never used the if, then with an iw-iterate before so I'm sure it's an issue with the searching for iw_value name. It's probably not finding dcr.reminder. I tried x.Anchor or x.Heading but that didn't make a difference either.
Suggestions on what I've done wrong?
Thanks,
...Jack
Find more posts tagged with
Comments
nipper
is this possibly in a replicant ? might it be something other than dcr.reminder ?
before your iw_if just put the tag for dcr.reminder and see what it says.
Everything looks good to me.
Andy
JeremyH
You probably don't need the 'ne ""' in your if expression. If there is something in the value, it should evaluate to true. Also, since it is a replicant, I'm not sure what it would evaluate to. (There is a data structure in there as opposed to a simple text value.)
JackB
No replicant or iterate outside of this, no. Only within it. There are other iterates in the .tpl, but they aren't part of this string.
I put:
<iw_value name='dcr.reminder'/>
in front of the iw_if and it didn't change anything to the output file.
...Jack
jbonifaci
I would suggest writing your entire tpl in one <iw_perl> tag. It makes tpls much easier to work with and maintain. You could do something like this:
<iw_perl>
my $outputHtml = '';
...
my $reminderHtml = '';
foreach my $reminder (iwpt_dcr_list('dcr.reminder'))
{
my $reminderAnchor = iwpt_dcr_value('reminder.Anchor');
my $reminderHeading = iwpt_dcr_value('reminder.Heading');
$reminderHtml .= <<" HTML";
<li class="sidelinks">
<a href="/html/Intr@Post/ste_ho.shtml#$reminderAnchor" class="sidelinks">$reminderHeader</a>
</li>
<br />
<br />
HTML
}
if ($reminderHtml ne '')
{
$outputHtml .= <<" HTML";
<p class="sidelinksTitle">Reminders:</p>
<br />
<ul>
$reminderHtml
</ul>
<br />
<hr width="165" noshade="noshade" class="sidelinkshr" />
HTML
}
...
iwpt_output($outputHtml);
</iw_perl>
~Jeff
jbonifaci
Jack,
If adding <iw_value name='dcr.reminder'/> did not change the output file, that would suggest that dcr.reminder is not returning anything. Thus, your expression:
<iw_if expn='{iw_value name="dcr.reminder"/} ne "" '>
is returning false, and the <iw_then is being skipped.
~Jeff
nipper
<iw_value name='dcr.reminder'/>
in front of the iw_if and it didn't change anything to the output file.
If you added this and there was no value in the output file, then the dcr.reminder is incorrect
It is null, which is why the iw_if fails
Check your DCT.
JackB
Didn't change anything to output file.
The DCT definitely has data. It was returning the data before I added the if then expressions.
...Jack
nipper
my question is are you seeing the value of reminder in the output that you generate ?
It was not intended to fix, just to verify you have the correct paramter
jbonifaci
Yes, so the point is, if dcr.reminder is not outputing anything, then your iw_if is going to fail, because dcr.reminder is not returining anything and therefor will be equal to "" and your iw_then will be skipped.
~Jeff
JackB
No I'm not seeing the value of reminder. The value of reminder is made up of x.Anchor and x.Heading - not seeing any of that. Reminder doesn't have a specific value.
jbonifaci
Why don't you remove the <iw_if> and <iw_then> tags and see if your output comes fine. The problem is likely with your <iw_if>, which doesn't look like it will work the way you want it to. For the exact reason that dcr.reminder does NOT have a value, you can't check to see if it is equal to "" or not.
~Jeff
JackB
Changing it to x.Heading or X.Anchor generates the same results as dcr.reminder. It doesn't go to the then results. How else should I be referring to the iterated dcr.reminder expression. I think that's the problem: because dcr.reminder iterates x.Anchor and X.Heading, the if expression isn't seeing them. If the if expression doesn't work with x.Heading or X.Anchor or dcr.reminder - what will?
Or can you not mix an iw_if expression with an iw_iterate?
JackB
I've already tested that. It works fine without the if then expression.
I want the if then expression because the client may occasionally leave this area of the form blank, so I don't want the Reminders area to come up on the output file.
jbonifaci
You can, but you can't access a variable inside your iterate from outside of it. Basically, you can't do what you're trying to do. You could include the if inside your iw_iterate and if it's the first iteration, then output the html that goes before and if it's the last iteration, output the html that goes after. But I would recommending doing it in perl, as I showed above.
~Jeff
JackB
Thanks for your help. I wanted to be sure. I'm not proficient in perl, so I'll have to make do without the if then expression.
Thanks again.
...Jack
training_report.rptdesign
flat files for forum help.doc