Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
Forum Search
Google Site Search
 All Forums
 Technical
 Tips and Tricks - HALL OF FAME
 Display customer search term on search results pg
Author « Topic »  

dbdave
ECT Moderator

USA
10415 Posts

Posted - 08/25/2018 :  17:15:20  
version 2.0
This works for both .asp and .php versions.
It is updaterproof, meaning this will not get overwritten when you update your store.
The code is slightly different for .asp and .php versions
This will work regardless if you are using the nobox=true parameter.
This is conditional so if no search term is entered, then nothing will display.
EDITED - Thanks to Marshall's post below, code has been edited to work with nobox setting.

It will show the text that the user searched for.
Link to demo below

==HOW TO INSTALL==

===ASP VERSION===

1. Open your search.asp page in your html editor.
2. In the content area of the page you will find the include line as follows
<!--#include file="vsadmin/inc/incsearch.asp"-->

Just above that, add the following line
<div class="searchedfor" id="searchedfor"></div>

3. Just below that, add the following
<script>
if ('<%=htmlspecials(request("stext"))%>' != '') {
var searchedfor = ('Showing results for: <%=htmlspecials(request("stext"))%>');
document.getElementById('searchedfor').innerHTML = searchedfor;
}
</script>

4. Upload to the server.
********************************************************************

===PHP VERSION===

1. Open your search.php page in your html editor.
2. In the content area of the page you will find the include line as follows
<?php include "vsadmin/inc/incsearch.php" ?>

Just above that, add the following line
<div class="searchedfor" id="searchedfor"></div>

3. Just below that, add the following
<script>
if ('<?php print htmlspecials($stext)?>' != '') {
var searchedfor = ('Showing results for: <?php print htmlspecials($stext)?>');
document.getElementById('searchedfor').innerHTML = searchedfor;
}
</script>

4. Upload to the server.
***************************************************************

This is written so nothing happens if no search term is entered and a visitor just navigates to the search page with no search term.
It can be styled with the class "searchedfor".
div.searchedfor {color:red; font-weight:bold; font-size:16px;} for example
The text there in the script Showing results for: can be changed to anything you like.

Demo here - http://www.floridasurpluswarehouse.com/dev/search.php?pg=1&stext=monitor
As stated, when no search term is entered, there is no output there http://www.floridasurpluswarehouse.com/dev/search.php

Enjoy...

Edited by - dbdave on 09/02/2018 10:56:08

Marshall
Ecommerce Template Guru

USA
1909 Posts

Posted - 08/25/2018 :  20:19:32  
For ASP, put <%=htmlspecials(request("stext"))%> where you want the terms to appear, e.g.
<meta name="description" content="Search results for '<%=htmlspecials(request("stext"))%>' ">

For PHP, put
<?php
$stext=getrequest('stext');
?>
above where you want the terms to appear then
<meta name="description" content="Search results for '<?php print htmlspecials($stext)?>' ">

I use this method as shown, both ASP and PHP, and it works very well.

Marshall
CENLYT Productions - ms designs
Affordable Web Design
Custom Ecommerce Designs
Responsive Websites
Cenlyt.com

Steved
Ecommerce Template Guru

United Kingdom
1022 Posts

Pre-sales questions only
(More Details...)

Posted - 09/03/2018 :  02:10:51  
Thanks for sharing this Dave - it works very well.

Steve
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.02 seconds. Snitz Forums 2000