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 :
Enhanced Next 10 Hack for WebStore  
sent in the following hack...

I have been a web_store user/beleiver and paid support user for over 4 years now,
and I have made great use of the Cool Hacks page at Extropia. Ignacio taught me
alot of cool things by utilizing the paid support, it tends to make you stretch your
imagination a bit.

Now I am ready to contribute to the hacks line-up if I may. BTW. this hack will work
best with scripts that already utilize the View next 10 Hits hack
(http://www.extropia.com/hacks/webstore/travis_ws.html), and I also utilize a db only
version of web_store for on-the-fly (OTF) page generation of product listings.

This hack makes the search results within web_store smarter... so to say.

*The first improvement of my hack addressess empty searches where no product
or db rows are returned by any keyword searches. Empty searches will receive a
screen telling the visitor ""I'm sorry, but your search for ""keyword"" has turned up
0 results"" which also offers a JS history back text link to the page with the search
pad itself.

*The final improvement of the hack deals with a search that returns 9 items lets say
in this example. If a visitor searches for ""vowels"" and the search returns 9 db rows
that pertain to the search criteria, and you have $sc_db_max_rows_returned set to 5.
Your first 5 rows will display and the visitor may view those individual products on the
first search results page. Once the visitor is done viewing the first results page he or
she is left with the ""Next 5 Hits Seen"" form at the base of that page. When this form
is submitted the last available db rows are displayed, but at the bottom of this page,
beings the search only returned 9 db rows and you are now viewing the last 4 db rows
of the search, the visitor now receives a notice informing them that ""Your search for
""keywords"" is completed"".

Installation Instructions:

1. In web_store.cgi, search for: $search_request = $form_data{'search_request_button'};
Now, just below this line you will insert this line: $search_request = $form_data{'next_result'};

$search_request = $form_data{'search_request_button'};
$search_request = $form_data{'search_request_button'};
$search_request = $form_data{'next_result'};

2.In web_store_html.pl, search for:

   if ($total_rows_returned >= $hits_seen) 
    $warn_message = qq!
 <INPUT TYPE = "hidden" NAME = "hits_seen" VALUE= "$hits_seen">
 <INPUT TYPE = "submit" NAME = "next_result"  
  VALUE = "Display Next $sc_db_max_rows_returned Results">
Now you will want to replace the above line with the following
    if ($total_rows_returned >= $hits_seen) 
    $warn_message = qq!
 <INPUT TYPE = "hidden" NAME = "hits_seen" VALUE= "$hits_seen">
 <INPUT TYPE = "submit" NAME = "next_result"  
  VALUE = "Display Next $sc_db_max_rows_returned Results">
    elsif ($hits_seen ne "$total_rows_returned" && $total_rows_returned == "")
    $warn_message = qq!
    <HR WIDTH=60% SIZE=2 COLOR=#000000><BR>
    <FONT CLASS=notfound><DIV ALIGN=CENTER>I am sorry, but your search for</FONT>
<FONT CLASS=notfound2> ($form_data{'keywords'})</FONT> <FONT CLASS=notfound>returned</FONT>
<FONT CLASS=notfound2>0</FONT> <FONT CLASS=notfound>results</FONT><P>
<FONT CLASS=notfound3>Won't you please try a different</FONT>
<A HREF=javascript:history.back(1) CLASS=notfound3>search?</A></DIV>
<BR><HR WIDTH=60% SIZE=2 COLOR=#000000>!; } elsif ($form_data{'search_request_button'} && $form_data{'next_result'} && $total_rows_returned == $hits_seen ) { $warn_message = qq! $sc_product_display_footer!; } elsif ($form_data{'next_result'} && $hits_seen >= "") { $warn_message = qq! <FONT CLASS=notfound><DIV ALIGN=CENTER>Your search for</FONT> <FONT CLASS=notfound2>
($form_data{'keywords'})</FONT> <FONT CLASS=notfound>is completed<BR>
<FONT CLASS=notfound3>Try using Quick Jump at the top right of this</FONT>
<A HREF=#top CLASS=notfound3>page.</A></DIV></FONT>!; }

3.Now also in web_store_html.pl, you will need to change the name of the Submit form in the beginning
of the above change from ""search_request_button"" to ""next_result""

<INPUT TYPE = "submit" NAME = "search_request_button"  
  VALUE = "Display Next $sc_db_max_rows_returned Results">
<INPUT TYPE = "submit" NAME = "next_result"  
  VALUE = "Display Next $sc_db_max_rows_returned Results">
Sub-Note for instruction 3:
If your search pad is in any non script parsed pages I.E. your home page in the virtual directory,
you will also need to place this hidden tag within the form tags for the error screens to work properly.
+ any Product directory based pages of web_store too that may have a search pad in them! <FORM ACTION=SHIBBLESHABBLE.COM METHOD=POST> <INPUT TYPE = "hidden" NAME = "hits_seen" VALUE= "$hits_seen"> </FORM>

4. Now, in web_store_html.pl, you will need to search for : ""sub make_hidden_fields"". This is the location of the script which generates hidden form tags OTF. Go just below the above sub name, and look for ""$hidden"". Here you will need to insert the following hidden tag in addition to any others that are already in existence:

<INPUT TYPE = HIDDEN NAME = next_result VALUE = $next_result>

Well, B B B B B B That's ALL FOLKS! Have fun and enjoy Warmest Regards Pat Taylor/EarthStations