Cart-Lab Blog

X-Cart & E-commerce related news, resources and tips. Postings by: B00MER of Cart-Lab.com


Saturday, February 04, 2006

Google Mini Implementation with PHP/X-Cart

1) Customer enters "foo" in search which submits to custom PHP file created for the steps following (2-5).

2) "foo" is normalized within the PHP file in different manners to help prevent any unwanted characters. (URI Escaping, white space removal, etc.)

3) A request is formed that will be passed to the Google mini via PHP function: fsockopen(); This is a normal HTTP 1.0 GET method request with our substring keyword "foo" Other boolean flags for the mini to return the proper results we need to parse in the next steps. Which include Filtering, Localization, Sorting, Custom Meta Tags (this is where author and other such fields can be sorted upon) and Limits on results that Mini needs.

4) An event handler is created for the fsockopen(); function that will handle the XML results Mini returns to PHP.

5) The event handler function contains a simple XML parser built with expat that will extra all necessary data needed. All collected data that was parsed from the XML is then passed along to X-Cart's template engine (Smarty).

6) This allows for the .tpl file to be created in the next step which is where all of our formatting as well as menu's such as Paging navigation and Filtering. These are merely new query string GET URI variables that are passed along to Google Mini in step 3. (See Request search variables: num,start, and sort)

7) After a user follows a navigation link like filtering, navigation paging or enters a new string to search for; All steps are then repeated with different requests in the URI that would then be interrupted to allow for different results easily.
---
REFERENCES
Google API XML Results used in this example: http://code.google.com/gsa_apis/xml_reference.html

PHP Documenation on fsockopen function:
http://www.php.net/fsockopen

Details on expat and XML parsing with PHP:
http://www.zend.com/zend/art/parsing.php

Smarty template engine:
http://smarty.php.net

X-Cart:
http://www.x-cart.com/

Labels: , , ,

Blinkbits
co.mments
Delicious
digg
Furl it!
NewsVine
Reddit
Spurl
TailRank
DZone
Google Bookmarks
taggly
Windows Live Favorites
addtoany
technorati



0 Comments:

Post a Comment

<< Home