Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
iw_ostrem
Tob
How can I use perl to determine if an iw_ostream buffer is output to a file based upon a DCR value......
<iw_perl>
<![CDATA[
my $isPrinterFriendly = iwpt_dcr_value('dcr.Printer Friendly');
if ($isPrinterFriendly eq 'T')
{
<iw_ostream buffer='moo' file='a.htm.'/>
}
]]>
</iw_perl>
Find more posts tagged with
Comments
ProfessorX
Please explain more..and on what u r trying to do..it is not clear
The Professor-
Tob
In my Datacapture.cfg I have a checkbox item named "Printer Friendly". When this option is checked I would like to do two things.
1. Use iw_ostream to generate a Printer Frienly version of the Generated output file (No Headers & Footers).
2. Add a link to a printer friendly version of the Generated Output.
First I set a variable if the PrinterFriendly checkbox is checked.
my $isPrinterFriendly = iwpt_dcr_value('dcr.Printer Friendly');
Next I Dynamically create a name for the PrinterFriendly Version of the file with the following code.
$ofile = TeamSite:
T::iw_xml::get_ofile_name($iw_parser);
$_ = $ofile;
s|\.aspx|PrinterFriendly\.aspx|mg ;
s|.*(docroot\\.*)|$1|mg;
s|\\|/|mg;
$ofile = $_;
If the checkbox is checked I am able to add the link to the PrinterFriendly version of the Output File.
<iw_perl>
<![CDATA[
if ($isPrinterFriendly eq 'isPrinterFriendly')
{
iwpt_output("<td align=\"right\"><a href=\"$ofile2\" TARGET=\"_new\">Printer Friendly Version</a></td>");
}
]]>
</iw_perl>
If the Printer Friendly Checkbox is not checked, the link is not added to the Generated file, HOWEVER, if the Printer Friendly option is checked OR not checked the PrinterFrienly version of the file is ALWAYS created. I want to create the file ONLY if the Printer Friendly option is checked.
See code that does not work below. Again, the PrinterFriendly version is ALWAYS created. I only want to create it if the Printer Friendly checkbox is checked.
<iw_ostream buffer='moo'>
<![CDATA[
<html>
<head>
<title>]]><iw_value name='dcr.Title' /><![CDATA[</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META NAME="author" CONTENT="]]><iw_value name='dcr.Changed By' /><![CDATA[">
</head>
<body>
<table id="Table1">
<tr>
<!-- Page Content -->
<td height="100%" width="80%" valign="top">
<table border="0" width="100%" cellpadding="8" cellspacing="0" id="Table2">
<tr>
<td>
<h1>]]><iw_value name='dcr.H1 / Page Title' /><![CDATA[</h1>
<hr size="8">
<h2>]]><iw_value name='dcr.H2' /><![CDATA[</h2>
</td>
</tr>
<tr>
<td valign="top">
]]><iw_value name='dcr.Body' /><![CDATA[
</td>
</tr>
</table>
</td>
<!-- Content Ends Here -->
</tr>
</table>
</body>
</html>
]]>
</iw_ostream>
<iw_perl>
<![CDATA[
if ($isPrinterFriendly eq 'isPrinterFriendly')
{
<iw_ostream buffer='moo' file='$ofile'/>
}
]]>
</iw_perl>
Thanks!!!
ProfessorX
Oh...so sorry to get back to you so late.
iw_ tags always get interprated
You CANNOT do this....
<iw_perl>
<![CDATA[
if ($isPrinterFriendly eq 'isPrinterFriendly')
{
<iw_ostream buffer='moo' file='$ofile'/>
}
]]>
</iw_perl>
This is what you have to do...
if ($isPrinterFriendly eq 'isPrinterFriendly')
{
$obuffer = "whatever";
$out_file= "PrinterFriendly.html";
}
<iw_ostream buffer='{iw_value name="$obuffer"/}' mode='docroot'>
----The stuff you want to print goes here ----
</iw_ostream>
<iw_ostream buffer='{iw_value name="$obuffer"/}' mode='docroot' file='$out_file'/>
You'll have to tweak a bit but you should get the jist...
The Professor-