📄 ch13.htm
字号:
<BR>
</TT><A HREF="14wpp02.jpg" tppabs="http://210.32.137.15/ebook/Web%20Programming%20with%20Perl%205/14wpp02.jpg"><TT><B>Figure 13.2.</B></TT></A> The description
search page. <BR>
<BR>
The next page to look at is the browse page. The code for it is shown in Listing
13.3. This page is similar to the <TT>descsrch</TT> page except that it gives the
user some categories from which to choose. Many of the MiniVend tags may look familiar
to you after seeing the search page.
<H3 ALIGN="CENTER"><A NAME="Heading17"></A><FONT COLOR="#000077">Listing 13.3. The
browse page.</FONT></H3>
<PRE><FONT COLOR="#0066FF"><HTML><HEAD>
<TITLE>Browse the Web Shopping Network by Category</TITLE>
</HEAD>
<BODY>
<H1>
Browse the Web Shopping Network by Category
</H1>
<P>
<FORM ACTION="[process-search]" METHOD=POST>
<STRONG>Category</STRONG><BR>
<SELECT NAME="mv_searchspec">
<OPTION VALUE="HomeAudio$"> Home Audio
<OPTION VALUE="HomeVideo$"> Home Video
<OPTION VALUE="CarAudio$"> Car Audio
<OPTION VALUE="Computers$"> Computers
<OPTION VALUE="Accessories$"> Accessories
</SELECT>
<INPUT TYPE=HIDDEN NAME="mv_case" VALUE="yes">
<INPUT TYPE=HIDDEN NAME="mv_orsearch" VALUE="yes">
<INPUT TYPE="hidden" NAME="mv_search_page" VALUE="results">
<P>
<INPUT TYPE="submit" NAME="mv_todo" VALUE="Search">
<INPUT TYPE="hidden" NAME="mv_doit" VALUE="search"><BR>
<P>
[finish-order]
Matches per page:
<SELECT NAME="mv_matchlimit">
<OPTION>5
<OPTION>10
<OPTION SELECTED>25
<OPTION>50
</SELECT><BR>
</FORM>
Just select one or more categories you wish to browse, then press the
<B>Search</B> button.
<P>
</BODY> </HTML>
</FONT></PRE>
<P>As you see, the only real difference with this page is the <TT>mv_searchspec</TT>
field. Rather than provide an empty text field here, you assist the user by providing
a list of categories from which to choose, as you can see in Figure 13.3. You might
be curious about the <TT>[finish-order]</TT> MiniVend tag in these last two HTML
files. I explain this tag in the next section on displaying the search results. <BR>
<BR>
<A HREF="14wpp03.jpg" tppabs="http://210.32.137.15/ebook/Web%20Programming%20with%20Perl%205/14wpp03.jpg"><TT><B>Figure 13.3.</B></TT></A> The Browse by Category
page.
<H4 ALIGN="CENTER"><A NAME="Heading18"></A><FONT COLOR="#000077">Displaying Search
Results</FONT></H4>
<P>Now that you've seen how to set up the search pages, you need to figure out how
to display the results from the search operation. To display results, you need a
few more MiniVend tags that enable you to display a list of items. This page, coded
in Listing 13.4, can be kept fairly generic as you will see. Most of the text on
the page is filled in by MiniVend based on the contents of your product database.
<H3 ALIGN="CENTER"><A NAME="Heading19"></A><FONT COLOR="#000077">Listing 13.4. The
results display page.</FONT></H3>
<PRE><FONT COLOR="#0066FF"><HTML><HEAD>
<TITLE>Search Results</TITLE>
</HEAD>
<BODY>
<H1>
Search Results
</H1>
<P>
[finish-order]
<P>
<H2>
[more-list]
Matches [matches] of
[/more-list]
[value mv_search_match_count]
items found</H2>
<P>
<TABLE BORDER>
<TR>
<TH>Item #</TH><TH>Description</TH><TH></TH><TH></TH><TH>Everyday Low Price</TH>
</TR>
[search-list]
<TR>
<TD><B>[item_increment]</B></TD>
<TD>[item-description]<BR></TD>
<TD>[item-link]</TD>
<TD>[order [item-code]]<STRONG>Order</STRONG>[/order]</TD>
<TD><B>Our Everyday Low Price $[item-price]</B><p></TD>
</TR>
[/search-list]
</TABLE>
<HR>
[more-list]
<B>There's even more to choose from!:</B><BR>
[more]
<HR>
[/more-list]
<TABLE>
<TR>
<TD>[page browse]Browse by Category[/page]</TD>
<TD>[page search]Search[/page]</TD>
<TD>[page catalog]Home[/page]</TD>
</TR>
</TABLE>
<P>
</BODY></HTML>
</FONT></PRE>
<P>The first tag that needs explanation here is the<TT> [finish-order]</TT> tag.
This tag inserts a link to the order page, giving the customer a quick way to place
his or her order. If no items are in the customer's shopping cart, this tag is ignored.
Another interesting tag in this page is <TT>[more-list]</TT>. This tag directly relates
to the <TT>mv_matchlimit</TT> of the previous page. It provides the user with a scrollable
list of items. Of course, this list comes into play only if the <TT>mv_matchlimit</TT>
value is exceeded. The <TT>[matches]</TT> tag displays the current range the customer
is viewing. If you've done any kind of Web searching, you should already be familiar
with this concept.</P>
<P>After displaying the number of items found using the <TT>[value]</TT> tag along
with the <TT>mv_search_match_count</TT> variable, you begin listing the items by
using the<TT> [search-list]</TT> tag. Once inside the <TT>[search-list]</TT>, you
can represent each item in any way that HTML allows. One of the best ways to display
this type of list is to use a table, as done in Listing 13.4. <TT>[item-increment]</TT>
specifies the index number of the item within the search results. <TT>[item-description]</TT>
displays the item's Description field value from your product database. <TT>[item-link]</TT>
provides a quick link to more information about that item. The way this link works
is pretty cool. You can create a page called <TT>flypage.html</TT>, which will be
the template for generating this page on the fly from the information in your database.
The next column gives the user a link to be able to order the item. It uses the <TT>[order]</TT>
tag together with the <TT>[item-code]</TT> tag. The <TT>[order]</TT> tag provides
a link to the order page, enabling the user to place his or her order. The <TT>[item-code]</TT>
is a necessary parameter to the <TT>[order]</TT> tag, which is extracted from the
product database. This parameter tells MiniVend which item is being ordered. The
last tag within the search list is <TT>[item-price]</TT>, which, of course, displays
the price of the item as listed in the product database. Figure 13.4 shows search
results using a textual search on the database, and Figure 13.5 shows results using
a category search. <BR>
<BR>
<A HREF="14wpp04.jpg" tppabs="http://210.32.137.15/ebook/Web%20Programming%20with%20Perl%205/14wpp04.jpg"><TT><B>Figure 13.4.</B></TT></A> The search results
from a textual search. <BR>
<BR>
<A HREF="14wpp05.jpg" tppabs="http://210.32.137.15/ebook/Web%20Programming%20with%20Perl%205/14wpp05.jpg"><TT><B>Figure 13.5.</B></TT></A> The search results
from a category search. <BR>
<BR>
You are now close to finished with your shopping site. The last major page to define
is your order page. On this page, you specify what information you want to obtain
from the customers when they place their orders and get information about items in
their virtual shopping carts.
<H4 ALIGN="CENTER"><A NAME="Heading20"></A><FONT COLOR="#000077">Setting Up Your
Order Page</FONT></H4>
<P>The order page probably has the most raw HTML code. This page defines all the
fields pertaining to customer information, as well as a list of items to be ordered.
Fortunately, MiniVend maintains the item list for you, and you can extract it by
using a few simple MiniVend tags. You define the customer input fields, which are
contained in your order reports. You can maintain persistent values for these fields
by using the <TT>[value]</TT> tag. This means that when a user fills out the order
form page, leaves it to find another item, and then comes back to the order page,
all the information he or she originally entered is not lost. The order page code
is shown in Listing 13.5.
<H3 ALIGN="CENTER"><A NAME="Heading21"></A><FONT COLOR="#000077">Listing 13.5. The
order page.</FONT></H3>
<PRE><FONT COLOR="#0066FF"><HTML><HEAD>
<TITLE>Place an Order</TITLE>
</HEAD>
<BODY>
<H1>Place an Order</H1>
<FORM ACTION="[process-order]" METHOD=POST>
<H2>Items to be ordered</H2>
<PRE>
[item-list]
[row 80]
[col 10]
[item-code]
[/col]
[col align=i width=10 gutter=1]
<input type="text" name=[quantity-name] value="[item-quantity]" size=4>
[/col]
[col 40]
[item-description]
[/col]
[col 16 align=r]
$[item-price]
[/col]
[/row]
[/item-list]
[row 80]
[col 10][/col]
[col 10][/col]
[col width=40 align=r wrap=no]
SUBTOTAL
[/col]
[col width=16 align=r]
[subtotal]
[/col]
[/row]
[row 80]
[col 10][/col]
[col 10][/col]
[col width=40 align=r wrap=no]
Sales Tax
[/col]
[col width=16 align=r]
[salestax]
[/col]
[/row]
[row 80]
[col 10][/col]
[col 10][/col]
[col width=40 align=r wrap=no]
Shipping
[/col]
[col width=16 align=r]
[shipping]
[/col]
[/row]
[row 80]
[col 10][/col]
[col 10][/col]
[col width=40 align=r wrap=no]
TOTAL
[/col]
[col width=16 align=r]
[total-cost]
[/col]
[/row]
</PRE>
<I>(If you wish to cancel the order on an item, simply enter
"0" in the quantity field of that item.)</I>
<P>
<I>
(If you change the quantity field of an item, you can recalculate the
new total by selecting "Refresh" below).
</I>
<P>
<B>Shipping via</B>
<INPUT TYPE=RADIO NAME=mv_shipmode
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -