View Single Post
  #43  
Old 12-29-2006, 11:22 AM
 
nfc5382 nfc5382 is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 481
 

Default Re: V4 - auto search using vars in url

Quote:
Originally Posted by intel352
4.1 already has the functionality, was looking at the code this morning, it crafts a "GET" url when search results are accessed. my assumption is it then redirects to that url or maybe provides a link in the content saying "link to these search results"

[/code]


I added the following with the BCSE free mod and that from 4.1:

BCSE mod: http://forum.x-cart.com/showthread.php?t=18488

search.php
Code:
x_session_register("search_data"); # BCSE begin if($search) { $search_data['products']['substring']=$search; $mode="search"; } # BCSE end if (!empty($search_data["products"])) { # only show fields we really care about $allowable_search_fields = array( "substring", "sort_field", "sort_direction" ); $search_url_args = array(); # from 4.1 foreach ($search_data["products"] as $k=>$v) { if (in_array($k, $allowable_search_fields) && !empty($v)) { if (is_array($v)) { foreach ($v as $k1=>$v1) $search_url_args[] = $k."[".$k1."]=".urlencode($v1); } else { $search_url_args[] = "$k=".urlencode($v); } } } # show page if needed if ($search_url_args && $page > 1) $search_url_args[] = "page=$page"; $search_url = "search.php?mode=search".(!empty($search_url_args) ? "&".implode("&", $search_url_args) : ""); $smarty->assign("search_url", $search_url); }

customer/main/search_results.tpl

paste this where you want the link to display:
Code:
<DIV align="right"><A href={$search_url}>This page URL</A></DIV>
__________________
-----------------------
x-cart v4.7.6 [LIVE]
x-cart v4.0.18 [retired 2004-2016]
x-cart v3.5.13 [retired]
x-cart v3.4.14 [retired]
Reply With Quote