Spooky's Databases >
Modify the DRW
> Spooky Diet
The code relies a
lot on the web bot code to regenerate the Wizard that defines the DRW.
Whilst this code is necessary when you are developing code, you may find
it no longer serves any purpose afterwards.
Why bother put the
code on a diet then?
Well, page size is
the main reason.
I've seen basic database results pages that weigh in at 500 - 1000 k
(One meg!)
The general rule of
thumb, is to not make the user download more than 20 - 100k. Otherwise,
they may get tired of waiting and leave. Ever tried waiting for a 1000k
page to display via Modem? Yep.....
This extra code
size, or "bloat" is caused by the repetition of the Wizard code FOR EACH
LINE.
In the Spooky Diet, I'll show you how to reduce the outputted code size
by a large amount!
The example below,
is only a simple "one column" database, but the code size is reduced
from 20k to 2k!!
Imagine the advantages as you add more columns and more lines!
Here we use our previous example. Note,
obviously, that your code may appear slightly different, BUT the code
that is left, will always be the same. The only code that varies, is the
code we will remove.
DISCLAIMER!!
Always keep a copy of the page you are about to modify. Spooky will not
be responsible for the frustration of deleting something with out having
a backup! (Much like me rewriting this page now, but that's a different
story....)
<table
width="100%"
border="1">
<thead>
<tr>
<td><b>ProductID</b></td>
</tr>
</thead>
<tbody>
Here's the first piece of code
below that's not required.
Delete it!
<SNIP>
<!--webbot bot="DatabaseRegionStart" startspan
s-columnnames="ProductID,ProductName,SupplierID,CategoryID,
QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder
,ReorderLevel,Discontinued"
s-columntypes="3,200,3,3,200,6,2,2,2,11"
s-dataconnection="Sample"
b-tableformat="TRUE"
menuformat="FALSE"
s-menuchoice
s-menuvalue
b-tableborder="TRUE"
b-tableexpand="TRUE"
b-tableheader="TRUE"
b-listlabels="TRUE"
b-listseparator="TRUE"
i-ListFormat="6"
b-makeform="FALSE"
s-recordsource="Products"
s-displaycolumns="ProductID"
s-criteria s-order s-sql="SELECT * FROM Products"
b-procedure="FALSE"
clientside SuggestedExt="asp"
s-DefaultFields
s-NoRecordsFound="No records returned."
i-MaxRecords="256"
i-GroupSize="5"
BOTID="0"
u-dblib="_fpclass/fpdblib.inc"
u-dbrgn1="_fpclass/fpdbrgn1.inc"
u-dbrgn2="_fpclass/fpdbrgn2.inc"
tag="TBODY"
local_preview="<tr><td colspan=64 bgcolor="#FFFF00"
align="left" width="100%"><font color="#000000">Database
Results regions will not preview unless this page is fetched from a Web
server with a web browser. The following table row will repeat once for
every record returned by the query.</font></td></tr>"
preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left"
width="100%"><font color="#000000">This is
the start of a Database Results region.</font></td></tr>"
-->
</SNIP>
This code MUST stay.
It's the include file that does all the work, and shows the asp variables
that you can now manually edit.
<!--#include
file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT * FROM Products"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=1 align=left width=""100%"">No records
returned.</td></tr>"
fp_sDataConn="Sample"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include
file="_fpclass/fpdbrgn1.inc"-->
Here's the next
piece of code to go. Delete it!
<SNIP>
<!--webbot bot="DatabaseRegionStart" i-CheckSum="25969" endspan -->
</SNIP>
<tr>
<td>
Each ROW of the DRW
contains DRW code. It can all be removed and only leave the RED code
<SNIP>
<!--webbot bot="DatabaseResultColumn"
startspan
s-columnnames="ProductID,ProductName,SupplierID,CategoryID
,QuantityPerUnit,UnitPrice,UnitsInStock,
UnitsOnOrder,ReorderLevel,Discontinued"
s-column="ProductID"
b-tableformat="TRUE"
b-hasHTML="FALSE"
clientside local_preview="<font size="-1">&lt;&lt;</font>ProductID<font
size="-1">&gt;&gt;</font>"
preview="<font size="-1">&lt;&lt;</font>ProductID<font
size="-1">&gt;&gt;</font>" -->
<%=FP_FieldVal(fp_rs,"ProductID")%>
<-- This code must
stay!!
<!--webbot
bot="DatabaseResultColumn" i-CheckSum="17683"
endspan -->
</SNIP>
</td>
</tr>
Now we finish the
region by removing all of the footer information.
<SNIP>
<!--webbot bot="DatabaseRegionEnd"
startspan
b-tableformat="TRUE"
b-menuformat="FALSE"
u-dbrgn2="_fpclass/fpdbrgn2.inc"
i-groupsize="5"
clientside tag="TBODY"
local_preview="<tr><td colspan=64 bgcolor="#FFFF00"
align="left" width="100%"><font color="#000000">This
is the end of a Database Results region.</font></td></tr><TR><TD
ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><FORM><NOBR><INPUT
TYPE=Button VALUE=" |< "><INPUT TYPE=Button VALUE="
< "><INPUT TYPE=Button VALUE=" > "><INPUT
TYPE=Button VALUE=" >| "> [1/5]</NOBR></FORM></td></tr>"
preview="<tr><td colspan=64 bgcolor="#FFFF00" align="left"
width="100%"><font color="#000000">This is
the end of a Database Results region.</font></td></tr><TR><TD
ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64><NOBR><INPUT TYPE=Button
VALUE=" |< "><INPUT TYPE=Button VALUE=" < "><INPUT
TYPE=Button VALUE=" > "><INPUT TYPE=Button VALUE="
>| "> [1/5]</NOBR><BR></td></tr>" -->
</SNIP>
You MUST still leave
the include file below
Note, it is usually at the end of the code above, don't delete it by
mistake!
<!--#include
file="_fpclass/fpdbrgn2.inc"-->
And delete the last
line
<SNIP>
<!--webbot bot="DatabaseRegionEnd" i-CheckSum="62730" endspan -->
</SNIP>
</tbody>
</table>
So, our finished code
looks something like this!
<table
width="100%"
border="1">
<thead>
<tr>
<td><b>ProductID</b></td>
</tr>
</thead>
<tbody>
<!--#include
file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT * FROM Products"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=1 align=left width=""100%"">No records
returned.</td></tr>"
fp_sDataConn="Sample"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include
file="_fpclass/fpdbrgn1.inc"-->
<tr>
<td>
<%=FP_FieldVal(fp_rs,"ProductID")%>
</td>
</tr>
<!--#include
file="_fpclass/fpdbrgn2.inc"-->
</tbody>
</table>
However, there is a slightly easier
way!
Stephen Travis, MVP for FrontPage, wrote
this macro for us which achieves the same thing.
It will automate and speed up the task quite substantially.
|