Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Aiheen aloitti: spiros - huhtikuu 13, 2008, 07:04:15 AP

Otsikko: Creating links to search queries
Kirjoitti: spiros - huhtikuu 13, 2008, 07:04:15 AP
Is it possible to do that? Let's say I want to create a link for the word "test" searching topic subjects only, only in this board.

Something like this
http://www.simplemachines.org/community/index.php?action=search2;search=testing

works, but only for latin scripts (not for Greek):
http://www.simplemachines.org/community/index.php?action=search2;search=ελληνικά
Otsikko: Re: Creating links to search queries
Kirjoitti: karlbenson - huhtikuu 13, 2008, 11:41:50 AP
The search term needs to be urlencoded in order to work. Obviously most latin characters don't need urlencoding

http://www.simplemachines.org/community/index.php?action=search2;search=%CE%B5%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AC+
Otsikko: Re: Creating links to search queries
Kirjoitti: spiros - huhtikuu 13, 2008, 11:55:13 AP
Is there any easy/automatic way to do URL encoding?
Otsikko: Re: Creating links to search queries
Kirjoitti: karlbenson - huhtikuu 13, 2008, 11:58:13 AP
Its a PHP function.
http://uk.php.net/urlencode

so
urlencode('ελληνικά');

It would be more difficult to use it in posts.  Probably the easiest way would be to have someone write a urlencode bbcode
eg
http://www.simplemachines.org/community/index.php?action=search2;search=[ue]ελληνικά[/ue]
Otsikko: Re: Creating links to search queries
Kirjoitti: spiros - huhtikuu 13, 2008, 12:03:55 IP
Clever idea Karl! Maybe someone should make a mod for it, sounds like a useful thing to have.  ;)
Otsikko: Re: Creating links to search queries
Kirjoitti: Dannii - huhtikuu 13, 2008, 12:10:51 IP
Search (http://www.simplemachines.org/community/index.php?action=search2;search=%CE%B5%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AC)
[url=http://www.simplemachines.org/community/index.php?action=search2;search=ελληνικά]Search[/url]

Using the url tag works. (Though it doesn't return any results!)
Otsikko: Re: Creating links to search queries
Kirjoitti: spiros - huhtikuu 13, 2008, 12:15:56 IP
Cool! Easier than I thought.
I have already reported this problem here:

http://www.simplemachines.org/community/index.php?topic=234039.0

Is it possible though to have extra parameters in the search query, like which boards to search and to search only topic titles?
Otsikko: Re: Creating links to search queries
Kirjoitti: Dannii - huhtikuu 13, 2008, 12:28:45 IP
It is, though I can't remember what they are.
Otsikko: Re: Creating links to search queries
Kirjoitti: SleePy - huhtikuu 20, 2008, 02:19:02 IP
Yes its brd[]=x
Where x is the board id. You repeat that for each board id you want.
Of course this now gets messy urls :P
Otsikko: Re: Creating links to search queries
Kirjoitti: spiros - huhtikuu 20, 2008, 04:45:29 IP
It works! But how can one specify more than 1 board? I tried this but it did not work (searched only first board):

http://www.simplemachines.org/community/index.php?action=search2;brd[]=9,86;search=testing
Otsikko: Re: Creating links to search queries
Kirjoitti: Rumbaar - toukokuu 06, 2008, 08:45:00 IP
I hope this helps, this is the BASE64 encode string for a search on this forum for the term ελληνικά

YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MjMsNDUsMTI1LDgwLDQ4LDEyNCw0Nyw4Nyw4OCw5Miw5MywxMTcsMjYsNzUsMTMwLDMxLDQ0LDc0LDEwMywxMjMsMSwxMjYsMTksMzAsMjQsMzYsMjksMTQ1LDE0MSwxNDYsMTAsMjAsMTMyLDEzMywxMzQsMTM1LDksMTEsMTQ3LDE0OCw4NiwyLDEzNywzNywzLDM4LDYwLDMzLDc3LDEzOCw1OSw3OSwzNCw5NiwxMDYsNzIsMTE1LDUsNDAsNTYsMTE2LDQsNiw4LDQxLDM1LDUwLDUxLDEyOCwxMjl8InxzaG93X2NvbXBsZXRlfCd8fCJ8c3ViamVjdF9vbmx5fCd8fCJ8c29ydF9kaXJ8J3xkZXNjfCJ8c29ydHwnfHJlbGV2YW5jZXwifHNlYXJjaHwnfM61zrvOu863zr3Ouc66zqw=

Which decoded is:
advanced|'|1|"|brd|'|23,45,125,80,48,124,47,87,88,92,93,117,26,75,130,31,44,74,103,123,1,126,19,30,24,36,29,145,141,146,10,20,132,133,134,135,9,11,147,148,86,2,137,37,3,38,60,33,77,138,59,79,34,96,106,72,115,5,40,56,116,4,6,8,41,35,50,51,128,129|"|show_complete|'||"|subject_only|'||"|sort_dir|'|desc|"|sort|'|relevance|"|search|'|ελληνικά

I'm sure you can pass the decoded text to the search2 parameter, or alter to your desired search parameters.
Otsikko: Re: Creating links to search queries
Kirjoitti: spiros - elokuu 10, 2011, 07:25:43 AP
I cannot get this URL to work, any ideas as how I can pass in the search string more than one board?
Otsikko: Re: Creating links to search queries
Kirjoitti: Angelina Belle - elokuu 30, 2011, 11:33:28 AP
spiros,

Long time, no see!

The format is like the one KarlBenson suggested.

http://www.simplemachines.org/community/index.php?action=search2;search=%CE%B5%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AC+

http://www.simplemachines.org/community/index.php?action=search2;search=%CE%B5%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AC+

Rumbaar's suggestion is that you can build a search string, such as
advanced|'|1|"|brd|'|23,45,125,80,48,124,47,87,88,92,93,117,26,75,130,31,44,74,103,123,1,126,19,30,24,36,29,145,141,146,10,20,132,133,134,135,9,11,147,148,86,2,137,37,3,38,60,33,77,138,59,79,34,96,106,72,115,5,40,56,116,4,6,8,41,35,50,51,128,129|"|show_complete|'||"|subject_only|'||"|sort_dir|'|desc|"|sort|'|relevance|"|search|'|ελληνικά
And then base64encode it to give
YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MjMsNDUsMTI1LDgwLDQ4LDEyNCw0Nyw4Nyw4OCw5Miw5MywxMTcsMjYsNzUsMTMwLDMxLDQ0LDc0LDEwMywxMjMsMSwxMjYsMTksMzAsMjQsMzYsMjksMTQ1LDE0MSwxNDYsMTAsMjAsMTMyLDEzMywxMzQsMTM1LDksMTEsMTQ3LDE0OCw4NiwyLDEzNywzNywzLDM4LDYwLDMzLDc3LDEzOCw1OSw3OSwzNCw5NiwxMDYsNzIsMTE1LDUsNDAsNTYsMTE2LDQsNiw4LDQxLDM1LDUwLDUxLDEyOCwxMjl8InxzaG93X2NvbXBsZXRlfCd8fCJ8c3ViamVjdF9vbmx5fCd8fCJ8c29ydF9kaXJ8J3xkZXNjfCJ8c29ydHwnfHJlbGV2YW5jZXwifHNlYXJjaHwnfM61zrvOu863zr3Ouc66zqw=


And finally put this encoded string into the search URL:
http://www.simplemachines.org/community/index.php?action=search2;search=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MjMsNDUsMTI1LDgwLDQ4LDEyNCw0Nyw4Nyw4OCw5Miw5MywxMTcsMjYsNzUsMTMwLDMxLDQ0LDc0LDEwMywxMjMsMSwxMjYsMTksMzAsMjQsMzYsMjksMTQ1LDE0MSwxNDYsMTAsMjAsMTMyLDEzMywxMzQsMTM1LDksMTEsMTQ3LDE0OCw4NiwyLDEzNywzNywzLDM4LDYwLDMzLDc3LDEzOCw1OSw3OSwzNCw5NiwxMDYsNzIsMTE1LDUsNDAsNTYsMTE2LDQsNiw4LDQxLDM1LDUwLDUxLDEyOCwxMjl8InxzaG93X2NvbXBsZXRlfCd8fCJ8c3ViamVjdF9vbmx5fCd8fCJ8c29ydF9kaXJ8J3xkZXNjfCJ8c29ydHwnfHJlbGV2YW5jZXwifHNlYXJjaHwnfM61zrvOu863zr3Ouc66zqw=
Otsikko: Re: Creating links to search queries
Kirjoitti: Illori - elokuu 30, 2011, 11:40:56 AP
that last url did not give search results

LainaaSearch string must be less than %1$d characters long.
is all it gives.
Otsikko: Re: Creating links to search queries
Kirjoitti: Angelina Belle - elokuu 30, 2011, 12:13:40 IP
That's funny.  I thought it worked the first time I tried it.  I must have been mistaken.

I think a simple link to a custom page might be a bit tougher than spiros imagined.

Of course, with fewer boards listed, it might just come under the character limit. Whatever that is!