PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 07-30-2005, 11:55 PM   #1
innerfire
Green Mole
 
Join Date: Jul 2005
Posts: 2
Restricting search results by URL at the search form level

I know that this has been talked about a few times in the forum, and I have read through all posts, but know body has asked this specific question as far as I can tell. My site is broken up by different languages via sub-directories, for example, es.mysite.com and de.mysite.com. However, my search results once all domains are spidered are mixed. So, from each language area I want to restrict results to that sub-domain (which phpdig treats as a unique URL, which I like, thus making this much more easy). What is the code to simply add this variable into the form? I don't want the form on en.mysite.com to show results for anything other than en.mysite.com. I don't need any option buttons, just need to know how to pass the restriction along to the rest of the program (my php skills suck).
innerfire is offline   Reply With Quote
Old 07-31-2005, 09:58 AM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Try the following...

In search.php find:
Code:
if (ALLOW_RSS_FEED) {
And beforehand add:
Code:
if (!empty($_SERVER['HTTP_HOST']) && (empty($site) || $path == '-###-')) {
	if (empty($site)) {
		$temp_site = addslashes("http://".$_SERVER['HTTP_HOST']."/");
		$temp_query = mysql_query("SELECT site_id FROM ".PHPDIG_DB_PREFIX."sites ".
				"WHERE site_url = '$temp_site' LIMIT 1",$id_connect);
		$temp_row = mysql_fetch_row($temp_query);
		$site = $temp_row[0];
	}
	$path = '';
}
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 07-31-2005, 08:11 PM   #3
innerfire
Green Mole
 
Join Date: Jul 2005
Posts: 2
That almost worked. Now when I search from either
es.symptoms101.com or www.symptoms101.com the results are only being shown from www.symptoms101.com (english). Eventually this site will have Spanish, German, Italian, French, and maybe portuguese, so begin able to keep the sub domain results separate would be great when searching from the sub domain itself. So, the results of the above change are that all results are being shown in english, sourcing from www.symptoms101.com (which is where the search program is located).

A more confusing twist, and I don't understand the technicality of it, may be that the system is creating subdomains by making folders within www.symptoms101.com for example, es.symptoms101.com is located on the server at www.symptoms101.com/es/. That is why I was asking about specifying the "sub domain" via the form. Any ideas on how to make it work? The site is set up now with the two subdomains and the search is coded with your suggested changes (99.9% of my traffic is english speaking until the rest of the site gets spidered, probably in a week or so).

P.S. Love the smileys on this forum!
innerfire is offline   Reply With Quote
Old 08-01-2005, 09:36 AM   #4
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Set a PHP info page in the es subdirectory:
Code:
<?php phpinfo(); ?>
And call the PHP info page from a browser. Look for es.symptoms101.com on the page. Is it by HTTP_HOST or something else?

The code above was to attempt to get the correct site_id depending on what (sub)domain the user entered prior to searching, without having to change the HTML form on each page.

You might try using the following in the HTML form instead:
Code:
<input type='hidden' name='site' value='XX'/>
<input type='hidden' name='path' value=''/>
<input type='hidden' name='refine' value='1'/>
Where XX is the site_id number from the sites table.

You might may to tweak the HTML like so:
Code:
<input type='hidden' name='site' value='XX'/>
<input type='hidden' name='path' value='es/'/>
<input type='hidden' name='refine' value='1'/>
If the URLs in the sites table are www instead of subdomains.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Reply


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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search form Anton How-to Forum 0 11-15-2006 11:42 PM
search form 'remembering' previous search lukemack How-to Forum 0 12-16-2005 05:10 AM
Problem restricting search results Grenville Hamly How-to Forum 6 10-14-2004 06:19 PM
search form sites guskoul Troubleshooting 7 08-03-2004 01:55 PM
separting results and search form nicedream How-to Forum 2 12-08-2003 02:49 PM


All times are GMT -8. The time now is 03:28 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.