Description: This WebSmart example looks for an image and if that image is not found replaces it with a new image.
-
Start WebSmart go to File->New... In the new window select PHP Templates-> iSeries SQL-> A Simple Page.tpl"
-
Go to Attributes->Files, type in MU_ITMF for the file and XL_WEBDEMO for the file library. Click OK, and OK again.
-
-
In the PHP- Source Code tab after
global $wsnum;
add:
$b,$a, $image
So it looks like:
global $wsnum, $b,$a, $image ;
-
Replace:
function generic()
{
wrtseg('MainSeg');
}
With the following:
function generic()
{
// Make all global variables available here
foreach($GLOBALS as $arraykey => $arrayvalue)
{
if ($arraykey[0]!='_' && image != 'GLOBALS')
global $$arraykey;
}
$a = "http://esdi.excelsystems.com/websmart/Images/websmart.gif";
$b= "http://esdi.excelsystems.com/websmart/Images/websmart-sample-app-255x96.gif";
$image;
if (file_exists($a)){
$image=$a;
}
else{
$image=$b;
}
wrtseg('MainSeg');
}
-
In the MainSeg tab, immediately after the
< div id="contents">
Add:
<?php
echo "< img src=\"" . $image . "\">";
?>
So it looks like:
< div id="contents">
<?php
echo "< img src=\"" . $image . "\">";
?>
< /div>
</div> </div>
|