Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

Creating links to search queries

Aloittaja spiros, huhtikuu 13, 2008, 07:04:15 AP

« edellinen - seuraava »

spiros

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=ελληνικά

karlbenson


spiros

Is there any easy/automatic way to do URL encoding?

karlbenson

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]

spiros

Clever idea Karl! Maybe someone should make a mod for it, sounds like a useful thing to have.  ;)

Dannii

Search
[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!)
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

spiros

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?

Dannii

It is, though I can't remember what they are.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

SleePy

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
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

spiros

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

Rumbaar

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.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

spiros

I cannot get this URL to work, any ideas as how I can pass in the search string more than one board?

Angelina Belle

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=
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

Illori

that last url did not give search results

LainaaSearch string must be less than %1$d characters long.
is all it gives.

Angelina Belle

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!
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

Advertisement: