Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Add a true Google search to your X-cart.

 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #21  
Old 07-29-2003, 08:16 AM
  minorgod's Avatar 
minorgod minorgod is offline
 

X-Adept
  
Join Date: Sep 2002
Location: Arivaca, AZ
Posts: 402
 

Default

Are you running version 3.3.1? If not, you need to modify the search code to work with your version, which means you need to understand how your regular version works first and then look at the differences between your version and the regular version of the 3.3.1 search code. Once you've done that, it should be very easy to modify. If not, then you probably need to beef up your PHP knowledge at www.php.net and www.phpbuilder.com because I'm not planning on rewriting this search code until I upgrade my cart which will be in about 6 months. Good luck.
__________________
www.brettbrewer.com
Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more.
Reply With Quote
  #22  
Old 09-06-2003, 07:21 AM
  joshf's Avatar 
joshf joshf is offline
 

Advanced Member
  
Join Date: Jul 2003
Posts: 97
 

Default

One thing to note for everyone that isn't receiving results... Your site has to be spidered by Google before you will see any results.





jf
Reply With Quote
  #23  
Old 10-09-2003, 04:45 PM
  minorgod's Avatar 
minorgod minorgod is offline
 

X-Adept
  
Join Date: Sep 2002
Location: Arivaca, AZ
Posts: 402
 

Default Update of Google search code

I have modified my google search because it stopped working for no apparent reason. Here is my updated code for xcart based on the x-cart 3.3.1 search code. You'll have to figure out if it needs modification for newer versions....
Here's a copy of the two pages I modified. You'll still need the SOAP_Google.php class mentioned in my original post on this thread, these are just two replacements for the other code...

/customer/search.php
Code:
{* $Id: search_result.tpl,v 1.10 2002/10/11 12:43:43 ambal Exp $ *} { include file="location.tpl" last_location=$lng.lbl_search_results} {include file="customer/main/navigation.tpl"} {capture name=dialog} {include file="customer/main/products.tpl"} {/capture} {if $google_links eq ""} {include file="dialog.tpl" title=$lng.lbl_search_results content=$smarty.capture.dialog extra="width=100%"} {include file="customer/main/navigation.tpl"} {/if} {if $google_links ne ""} {capture name=google_results} {section name=google_link loop=$google_links} {$google_links[google_link]} {/section} {if $google_nav ne ""} {$google_nav} {/if} {/capture} {if $smarty.capture.google_results ne ""} {include file="dialog.tpl" title=$lng.lbl_search_results content=$smarty.capture.google_results extra="width=100%"} {/if} {/if}
/skindir/customer/main/search_result.tpl
Code:
<? /*****************************************************************************\ +-----------------------------------------------------------------------------+ | X-Cart | | Copyright (c) 2001-2002 Ruslan R. Fazliev. All rights reserved. | +-----------------------------------------------------------------------------+ | The Ruslan R. Fazliev forbids, under any circumstances, the unauthorized | | reproduction of software or use of illegally obtained software. Making | | illegal copies of software is prohibited. Individuals who violate copyright | | law and software licensing agreements may be subject to criminal or civil | | action by the owner of the copyright. | | | | 1. It is illegal to copy a software, and install that single program for | | simultaneous use on multiple machines. | | | | 2. Unauthorized copies of software may not be used in any way. This applies | | even though you yourself may not have made the illegal copy. | | | | 3. Purchase of the appropriate number of copies of a software is necessary | | for maintaining legal status. | | | | DISCLAIMER | | | | THIS SOFTWARE IS PROVIDED BY Ruslan R. Fazliev ``AS IS'' AND ANY | | EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | DISCLAIMED. IN NO EVENT SHALL Ruslan R. Fazliev OR ITS | | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | | | The Initial Developer of the Original Code is Ruslan R. Fazliev. | | Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2002 | | Ruslan R. Fazliev. All Rights Reserved. | +-----------------------------------------------------------------------------+ \*****************************************************************************/ # # $Id: search.php,v 1.35 2002/11/14 07:58:18 zorg Exp $ # require "../smarty.php"; require "../config.php"; @include "./https.php"; require "./auth.php"; require "../include/categories.php"; $tmp=strstr($QUERY_STRING, "PHPSESSID="); if (!empty($tmp)) $QUERY_STRING=""; //begin main if if(!empty($QUERY_STRING)) { # # Permorfm SQL search query # //BEGIN GOOGLE SEARCH CODE if ( isset($_GET['q'])){ require_once 'SOAP_Google.php'; // Configure the following to make this work on your site $nr = 10; // Number of results per page $smarty->assign("nr",$nr); $clef = 'WASMAvpQFHIvzqbg7pE0RlYBJXKGXiz8'; // your Google API key provided by Google $site_url = 'realestate-school.com'; // End of configuration section if (strlen($q) > 0) { $google = new SOAP_Google($clef); $result = $google->search(array( 'query' => $q.' site:'.$site_url, 'start' => $s, 'maxResults' => $nr, 'lr' => 'lang_en', 'filter' => true )); if ($result !== false) { // echo " Found about {$result['estimatedTotalResultsCount']} documents in {$result['searchTime']} seconds.</p>"; // echo " Displaying results {$result['startIndex']} through {$result['endIndex']}.</p>"; $res = $result['resultElements']; if( count($res) < $nr ){ $is_last_page=true; }else{ $is_last_page=false; } $i=$result['startIndex']; if (is_array($res)){ foreach ($res as $site) { $google_links[]= "$i.$site[title] $site[snippet]"; $i++; } $smarty->assign("google_links",$google_links); $smarty->assign("main","search"); //$smarty->assign("google_result",$result); }else{ $suggestion=$google->getSpellingSuggestion($q); if(!empty($suggestion)){ $google_links[]="No results found. <font size='2'>Did you mean: <a href='search.php?q=".$suggestion."'>".$suggestion."?</font>"; $google_links[]="Click here to search again."; }else{ $google_links[]="No results found matching your search term. Click here to search again."; } $smarty->assign("google_links",$google_links); $smarty->assign("main","search"); //$smarty->assign("google_result",$result); } //echo "<pre>"; //print_r($google_links); //echo "</pre>"; //echo "<div align='center'>"; if ($result['startIndex'] >= $nr) { $t = $result['startIndex'] - ($nr+1); $google_nav="<a href='search.php?q="; $google_nav.=urlencode($q); $google_nav.="&amp;s=0"; $google_nav.="'>first</a> | "; } if ($result['startIndex'] >= $nr) { $t = $result['startIndex'] - ($nr+1); $google_nav.="<a href='search.php?q="; $google_nav.=urlencode($q); $google_nav.="&amp;s="; $google_nav.=$t; $google_nav.="'>previous</a> | "; } //generate page links 1 | 2 | 3 | 4 | etc..... if ($result['estimatedTotalResultsCount'] > $nr ){ $number_pages = $result['estimatedTotalResultsCount'] / $nr; if($result['estimatedTotalResultsCount'] % $nr != 0){ $number_pages++; } for($i=0;$i<$number_pages;$i++){ //$t = $result['endIndex'] ;//+ 1; $t=$i*$nr; $google_nav.="<a href='search.php?q="; $google_nav.=urlencode($q); $google_nav.="&amp;s="; $google_nav.=$t; $google_nav.="'>"; //echo "i is $i and s is $s"; if($i * $nr == $s){ $google_nav.=""; }else{ $google_nav.="<u>"; } $google_nav.=$i+1; if($i * $nr == $s){ $google_nav.=""; }else{ $google_nav.="</u>"; } $google_nav.="</a> | "; } } //if (($result['estimatedTotalResultsCount'] > $result['endIndex']) || !$result['estimateIsExact'] || $result['startIndex'] >= $nr ){ // $google_nav.=" Navigation | "; //} if ((($result['estimatedTotalResultsCount'] > $result['endIndex']) || !$result['estimateIsExact']) && $is_last_page!=true ){ $t = $result['endIndex'] ;//+ 1; $google_nav.="<a href='search.php?q="; $google_nav.=urlencode($q); $google_nav.="&amp;s="; $google_nav.=$t; $google_nav.="'>next</a> | "; } if ((($result['estimatedTotalResultsCount'] > $result['endIndex']) || !$result['estimateIsExact']) && $is_last_page!=true){ $t = $result['endIndex'] ;//+ 1; $google_nav.="<a href='search.php?q="; $google_nav.=urlencode($q); $google_nav.="&amp;s="; $google_nav.=$result['estimatedTotalResultsCount']-1; $google_nav.="'>last</a>"; } $smarty->assign("google_nav",$google_nav); } } else { echo " There was a problem with the search request.</p>"; } //$smarty->assign("google_links",$google_links); $smarty->assign("main","search"); //$smarty->assign("google_result",$result); //END GOOGLE SEARCH CODE }else{ //begin regular store search if $_GET[q] was not submitted for google search $price_condition = $price_search_1?" AND $sql_tbl[pricing].price>='$price_search_1'":""; $price_condition .= $price_search_2?" AND $sql_tbl[pricing].price<='$price_search_2'":""; $sort_by_price = $price_condition?" ORDER BY price":""; $price_substring = $price_search_1?"&price_search_1=".urlencode($price_search_1):""; $price_substring .= $price_search_2?"&price_search_2=".urlencode($price_search_2):""; $search_category = addslashes(array_pop(func_query_first("select category from $sql_tbl[categories] where categoryid='$in_category'"))); //$search_query = "($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].descr like '%$substring%') and $sql_tbl[categories].category like '$search_category%' and $sql_tbl[products].forsale='Y' $price_condition ".$sort_by_price; $search_query = "($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].descr like '%$substring%') and $sql_tbl[categories].category like '$search_category%' and $sql_tbl[products].forsale='Y' $price_condition "; if ($current_area == "C") { $membership_condition = " AND ($sql_tbl[categories].membership='". $user_account['membership']."' OR $sql_tbl[categories].membership='') "; } else { $membership_condition = ""; } $search_query_count = "select count(*) from $sql_tbl[products], $sql_tbl[pricing], $sql_tbl[categories] where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[pricing].quantity=1 and $sql_tbl[products].categoryid=$sql_tbl[categories].categoryid $membership_condition and ($sql_tbl[pricing].membership='". $user_account['membership']."' or $sql_tbl[pricing].membership='') and ($sql_tbl[products].product like '%$substring%' or $sql_tbl[products].descr like '%$substring%') and $sql_tbl[categories].category like '$search_category%' and $sql_tbl[products].forsale='Y' $price_condition "; $total_products_in_search = array_pop(func_query_first($search_query_count)); # # Navigation code # $objects_per_page = $config["General"]["products_per_page"]; $total_nav_pages = ceil($total_products_in_search/$config["General"]["products_per_page"])+1; require "../include/navigation.php"; //$smarty->assign("products",func_search_products($search_query, $user_account['membership'],$first_page,$total_products_in_search)); $products=func_search_products($search_query, $user_account['membership'],$first_page,$total_products_in_search,$sort_by_price); $smarty->assign("products",$products); $smarty->assign("navigation_script","search.php?substring=".urlencode($substring)."&in_category=$in_category".$price_substring); $_GET['substring'] = stripslashes($_GET["substring"]); $smarty->assign("main","search"); }//end regular store search }//end main if else { $smarty->assign("main","advanced_search"); } $smarty->display("customer/home.tpl"); ?>
__________________
www.brettbrewer.com
Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more.
Reply With Quote
  #24  
Old 11-30-2003, 06:04 PM
 
ifalu ifalu is offline
 

Member
  
Join Date: Oct 2003
Posts: 28
 

Default Does this work with 3.50?

Does this work with 3.50?
Reply With Quote
  #25  
Old 12-01-2003, 07:24 AM
  minorgod's Avatar 
minorgod minorgod is offline
 

X-Adept
  
Join Date: Sep 2002
Location: Arivaca, AZ
Posts: 402
 

Default

I doubt it, but maybe. If it doesn't work, chances are it only needs minor modifications, but since I'm running an old version of x-cart, I have no way of knowing.
__________________
www.brettbrewer.com
Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more.
Reply With Quote
  #26  
Old 12-01-2003, 07:24 AM
  minorgod's Avatar 
minorgod minorgod is offline
 

X-Adept
  
Join Date: Sep 2002
Location: Arivaca, AZ
Posts: 402
 

Default

I doubt it, but maybe. If it doesn't work, chances are it only needs minor modifications, but since I'm running an old version of x-cart, I have no way of knowing.
__________________
www.brettbrewer.com
Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more.
Reply With Quote
  #27  
Old 12-01-2003, 07:25 AM
  minorgod's Avatar 
minorgod minorgod is offline
 

X-Adept
  
Join Date: Sep 2002
Location: Arivaca, AZ
Posts: 402
 

Default

I doubt it, but maybe. If it doesn't work, chances are it only needs minor modifications, but since I'm running an old version of x-cart, I have no way of knowing.
__________________
www.brettbrewer.com
Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more.
Reply With Quote
  #28  
Old 12-01-2003, 07:27 AM
  minorgod's Avatar 
minorgod minorgod is offline
 

X-Adept
  
Join Date: Sep 2002
Location: Arivaca, AZ
Posts: 402
 

Default

There was a PHP error when I tried to post that last comment so I inadvertantly posted 3 times. Someone may want to delete the extras since I can't.
The PHP errors were:

Warning: fsockopen(): php_hostconnect: connect failed in /usr/local/apache/htdocs/forum/includes/smtp.php on line 126

Warning: fsockopen(): unable to connect to qt-dev.crtdev.local:25 in /usr/local/apache/htdocs/forum/includes/smtp.php on line 126

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/htdocs/forum/includes/smtp.php:126) in /usr/local/apache/htdocs/forum/includes/page_header.php on line 449

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/htdocs/forum/includes/smtp.php:126) in /usr/local/apache/htdocs/forum/includes/page_header.php on line 450

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/htdocs/forum/includes/smtp.php:126) in /usr/local/apache/htdocs/forum/includes/page_header.php on line 451
__________________
www.brettbrewer.com
Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:44 PM.

   

 
X-Cart forums © 2001-2020