Here is another that I submitted:
Using TeamSite Templating Preview and iw_ostream
As templates get more complex, people are making multiple files from a single
presentation template using iw_ostream. However, during preview, the file naming in
iw_ostream is changed to prevent overwriting another file.
For example: if one has a DCR that creates a DotNet page, consisting of both
ascx and aspx pages. The aspx page has an include to read the ascx or body of the
page.
During normal operation, DCR foo.xml generates the file dir1/foo.aspx, it also uses an
invocation of iw_ostream to generate dir2/foo.ascx. In addition, foo.aspx has a reference telling
the webserver to include the ascx page when the aspx page is rendered.
However, during preview, the DCR foo.xml generates zz_tst_aknipp_7_1179869098321_aknipp_preview.aspx.
While the iw_ostream invocation specifies the ascx name to be dir2/foo.ascx, the
actual file created is named dir2/zz_tst_aknipp_1_foo.ascx. Thus the reference
in the aspx file to dir2/foo.ascx is incorrect. This causes the preview to
either be incorrect (rendering an old ascx file) or incomplete, where no
ascx file exists.
Fortunately the steps to fix this issue are not complex. All that needs to be
accomplished is that, during the process of creating the reference to the ascx in
the aspx page, for preview the new name should be calculated and used.
Example code follows:
my $DCR = iwpt_get_dcr_name();
$DCR =~ s/\\/\//g;
$DCR =~ m|(.+)templatedata/([^/]+)/([^/]+)/data/(.+)|;
my $wa = $1;
my $category = $2;
my $type = $3;
my $dcrbasename = $4;
my $mode = "";
for (my $i=0; $i<@ARGV; $i++)
{
if ($ARGV[$i] =~ /iw_pt-preview/)
{
$mode = "preview";
}
}
my $ascxlink = "";
if ($mode =~ m|preview|){
$ascxlink = "dir2/";
my $zzname=iwpt_get_ofile_name("basename");
$dcrbasename =~ s|\.xml$||;
$zzname =~ m|zz_tst_(.*?)_(.*?)_|;
my $name = $1;
my $num = $2;
$ascxlink .= "zz_tst_".$name."_".$num."_".$dcrbasename.".ascx";
} else {
$ascxlink = "dir2/".$dcrbasename.".ascx";
}