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)
Suppress output of generated file?
RonaldV
Hi,
is there a way to suppress the output of the generated file in the tpl code?
Say you want something like this:
if (a is true and b is false) {
generate output
} else {
exit and DO NOT generate a output file
}
Thanks, Ronald
Find more posts tagged with
Comments
tsrookie
Hi Ronald,
This might help look at iw_ostream
regards Colin
wrap your iw_ostream stuff in an iw_if statement
<iw_if expr="{iw_value name='dcr.fieldName'/} ne '' ">
<iw_then>
<iw_ostream file_val='linkPath'>
<iw_iterate var='docs' list='dcr.standard.related_info.doc_attributes'>
<![CDATA[<div class="sidebarBody"><a href="<iw_value name='docs.related_doc.doc_path.value'/>">]]><iw_value name='docs.related_doc.doc_display.value'/><![CDATA[</div></a>]]>
</iw_iterate>
</iw_ostream>
</iw_then>
<iw_else>
</iw_else>
</iw_if>
RonaldV
Thanks Colin,
That will sure work but I was hoping not to use ostream. I dislike it since it makes the tpl code less understandeble & you lose the like between the generated file & the dcr.
Do we have any other options?
Ronald
tsrookie
You don't have to lose the link between the generated code and the dct, look at the CLT iwextattr which allows you to attach TS extended attributes to the iw_ostream generated code.
Colin
Johnny
I had a need to only generate selected files via ostream, meaning the ofile was not needed.
EG, a home page template needed to produce 3 specified jsp includes.
Since we use a generic external task to generate, we managed to add an option into templating.cfg
<template extension="inc" ignoreOFile="t" name="homeportal.tpl">
We have a modified version of DTemplateParse.pm (It should already be posted in the tech library) that retrieved that extra field and the generic external task sets the ofile in iwpt_compile to null if it is true.
Sounds like more of a workaround than it actually is, but since we had practical uses for it, it works quite well.
Not sure how in line it sounds with you as this is always applied to a template type, rather than programically determining it in the PT.
John Cuiuli
civ3
Hi Ronald
If you are confident to use Perl, <iw_perl> tag should meet your requirement. You just put Perl codes within this tag and use iwpt_output to output the text you want.
Regads,
civ3