Table of Contents
In the simple example in the last chapter, we saw how to create a list of model's names with hypertext links on each name to that model's standard WACS model page. Obviously that's not a particularly presentable page by itself, so the next step is to add a head shot for each model to the links.
We actually already paved the way for doing this by including the two headshot image fields in the results we asked for from the SQL query - if you remember, we put:
select mname, modelno, mbigimage, mimage
Since we have the data already, all we need to do now is to add
a few extra statements to the output section to output an appropriate
image tag and we'll have included the model's headshot too. We have
a configuration attribute in the server section of
the configuration file called siteurl that tells
us where the site specific WACS web elements area can be found on the
WACS server.
Standard size
model headshots are conventionally found in the icons/
directory directly below the top level.
So all we need to do is add in a call to conf_get_attr to
get it and build the apropriate HTML img
tag. In
PHP we'd write:
print "<img src=\"".$wacs->conf_get_attr("server","siteurl"); print "icons/".$results[3]."\" alt=\"[".$results[0]."]\">";
and in perl we'd write:
print "<img src=\"".conf_get_attr("server","siteurl"); print "icons/".$results[3]."\" alt=\"[".$results[0]."]\">";
this needs to be done just below the line that establishes the
link to the model's WACS model page, but before her name (you could
put it after if you prefer) and closing </a>
.
Example 3.1. Modified Output Loop with Icon Code
while( $results = $cursor->fetchRow() ) { print "<li>"; print "<a href=\"".$wacs->conf_get_attr("server","cgiurl"); print "wacsmpthumbs/".$results[1]."\">"; print "<img src=\"".$wacs->conf_get_attr("server","siteurl"); print "icons/".$results[3]."\" alt=\"[".$results[0]."]\">"; print $results[0]."</a></li>\n"; }
and in perl this now looks like:
while( @results = $cursor->fetchrow_array ) { print "<li>"; print "<a href=\"".conf_get_attr("server","cgiurl"); print "wacsmpthumbs/".$results[1]."\">"; print "<img src=\"".conf_get_attr("server","siteurl"); print "icons/".$results[3]."\" alt=\"[".$results[0]."]\">"; print $results[0]."</a></li>\n"; }
We then copy up the modified version of the program and run it and we should see something like this: