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)
body of <iw_if> not working
rohitspathak123
I am trying to pass variable to another .tpl using $iw_param depending on the success of <iw_if>
The code snippet is
-----------------------------------------------
<iw_include pt="templatedata/nextel/commonModules/presentation/modules/item25_07.tpl">
<![CDATA[
$pageType = iwpt_dcr_value('contProDCR.contentProviderCategoryPage.pageType');
<iw_if expr=" $pageType eq 'Web Content Provider' ">
<iw_then>
$iw_param{abstract} = iwpt_dcr_value("contProRawDCR.serviceContentProviderRawDetail.webProviderAbstract");
</iw_then>
</iw_if>
<iw_if expr=" $pageType eq 'Alert Content Provider'"> <iw_then>
$iw_param{abstract} = iwpt_dcr_value('contProRawDCR.serviceContentProviderRawDetail.alertProviderAbstract');
</iw_then>
</iw_if>
]]>
</iw_include>
---------------------------------------------
I am not getting the value of my $iw_param{abstract} in CHILD TPL
But when I assign the value of $iw_param{abstract} outside the <iw_if> TAG then it is working fine . Also the value in $pageType is correct .
Find more posts tagged with
Comments
Chad_Hayton
My guess is that the code within the CDATA element is processed as Perl and therefore doesn't recognize your <IW_IF> statements. Have you tried using just plain old perl ?
--------------------------------------------------------------------------------------------------------------------------------
$pageType = iwpt_dcr_value('contProDCR.contentProviderCategoryPage.pageType');
if($pageType eq 'Web Content Provider'){
$iw_param{abstract} = iwpt_dcr_value("contProRawDCR.serviceContentProviderRawDetail.webProviderAbstract");
}
if($pageType eq 'Alert Content Provider'){
$iw_param{abstract} = iwpt_dcr_value('contProRawDCR.serviceContentProviderRawDetail.alertProviderAbstract');
}
--------------------------------------------------------------------------------------------------------------------------------
hitc
yep,iw_if will not be processed by perl if inside a CDATA tag.
Migrateduser
Close, Chad. The problem isn't that it's being treated as perl (that would be the case if it were in a CDATA inside an iw_perl tag). Since they have omitted it, the stuff in the CDATA will just go to the output and show up in the generated document. But, at the core, the problem is the CDATA tag, and you solution is a good one.
Chad_Hayton
Hi Rob. We keep meeting all over the place. ;-)
When I tested the Perl code I shared with rohitspathak123 from within a dummy TPL file it actually worked for me. Granted it was a simplified version if Rohi's code, but it looked something like this:
-----------------------------------------------
<iw_include pt="templatedata/somefile.tpl">
<![CDATA[
$iw_param{test} = "Initial param value";
$test = 1;
if($test){
$iw_param{test} = "New param value";
}
]]>
</iw_include>
---------------------------------------------
The TPL called in the include was passed the "new" param value when I $test to true and the "initial" param value when it was false anditi didn't throw any errors. My assumption was that since we are passing Perl hash values in the CDATA inside the IW_INCLUDE tag that other Perl code would also get interpreted. I ran my tests on TS 5.5.2 on Windows. Maybe I'm sneaking in the back door with this?
Chad--
Migrateduser
I'm pretty sure you are. In fact, I would go so far as to call it a bug if code outside of an iw_perl is getting eval'ed by the interpreter. That could be a giant PITA. Imagine if you were trying to put up a page demonstrating how to code something in perl and the template decided to get jiggy with your sample script.