eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Development resources
 ::   WebWare 2.1 (Perl)
 ::   WebWare 2.0 (Java)
 ::   Cool hacks
radical hacks
WebBBS File Attachment Enhancements  
sent in the following hack to add on to the one submitted by Travis...

"I have manipulated Travis' Next 10 Hits Web Store Hack to add a previous function.

I don't really know if the solution is elegant or not, but it works. Could you post this to your hack list?

Again, thanks for the tremendous service that extropia extends to the masses.

Herb Halstead
herb@hastech.com
H.A.S. Technologies, Inc.
http://www.has-tech.com

************************************************************************

Code to follow

In web_store.cgi...

This is what the original hack said to add to the CGI...
********************************************************

### Next 10 Hits Hack ##############
### voided line below
# ($status,$total_row_count) = &submit_query(*database_rows);
### New lines
                ($status,$total_row_count) = &submit_query(*database_rows,
$form_data{'hits_seen'});
                $hits_seen = $form_data{'hits_seen'} + $sc_db_max_rows_returned;
### End of Next 10 Hits Hack ##############


********************************************************
Code to follow

In webstore_html_lib.pl...
********************************************************
First, in the "product_page_footer" subroutine, move "$warn_message" to
directly after the "</form>" tag.

Also, this example uses "image" buttons (input type=image...) as "submit"
buttons... to do this, you must make web_store.cgi look for
"whatever_button.x" instead of "whatever_button" in the section where the
script tests for buttons.  Otherwise, you need to substitute conventional
"submit" buttons (input type=submit...) in place of my "image" buttons


### Next 10 Hits Hack
### voided lines
#  if ($db_status ne "")
#    {
#    if ($db_status =~ /max.*row.*exceed.*/i)
#     {
#      $warn_message = qq!
#      <CENTER>
#     <BLOCKQUOTE>
#     Your query returned $total_rows_returned.  This is more than
#      the maximum we allow ($sc_db_max_rows_returned). You will need to
#      restrict your query further.
#      </BLOCKQUOTE></CENTER><P>!;
#      }
#    }
### New Lines
#
### Check for next button and previous button
#
if ($hits_seen > 0)
        {
#
# the last page in a "next hits" sequence is usually less than the value we
have set for
# $sc_db_max_rows_returned, we want to be sure that if this page still gets
a "previous hits"
# button, otherwise, the user will have to use the back button.
#
        if ($hits_seen > $sc_db_max_rows_returned)
                {
             $hits_prev = $hits_seen - $sc_db_max_rows_returned -
$sc_db_max_rows_returned;
                      $warn_message = qq!
                        </form>
                        <center>
                        <table>
                        <td>
                        <form action = web_store.cgi method = post>$hidden
                        <input type = "hidden" name=category
value=$category>
                        <input type = "hidden" name=product value=$product>
                        <input type = "hidden" name="hits_seen"
value="$hits_prev">
                      <INPUT TYPE = "image" SRC = "../images/prev10.gif" NAME
= "search_request_button">
                        </form>
                        </td>
                        </table>
                        </CENTER>
                  !;
                }
#
# Now, if this sequence of lines is what determines if a "more hits" button
is needed. If
# it is, it then checks to see if a "previous hits" button is needed.
#
           if ($total_rows_returned >= $hits_seen)
              {
             $hits_prev = $hits_seen - $sc_db_max_rows_returned -
$sc_db_max_rows_returned;
             $warn_message = qq!
                        </form>
                        <center>
                        <table>
                  !;
              if ($hits_prev > -10)
                        {
                      $warn_message .= qq!
                        <td>
                        <form action = web_store.cgi method = post>$hidden
                        <input type = "hidden" name=category
value=$category>
                        <input type = "hidden" name=product value=$product>
                        <input type = "hidden" name="hits_seen"
value="$hits_prev">
                      <INPUT TYPE = "image" SRC = "../images/prev10.gif" NAME
= "search_request_button">
                        </form>
                        </td>
                  !;
                        } # end if $hits_prev
              $warn_message .= qq!
                        <td>
                        <form action = web_store.cgi method = post>$hidden
                        <input type = "hidden" name=category
value=$category>
                        <input type = "hidden" name=product value=$product>
                  <INPUT TYPE = "hidden" NAME = "hits_seen" VALUE="$hits_seen">
                  <INPUT TYPE = "image" SRC = "../images/next10.gif" NAME= "search_request_button">
                        </form>
                        </td>
                        </table>
                        </CENTER>
                  !;
              } # end if $total_rows_returned
} # end if ($hits_seen > 0)
### End of Next 10 Hits Hack