Welcome, Guest. Please login or register.
Did you miss your activation email?
May 22, 2012, 03:10:24 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155365 Posts in 21695 Topics by 7729 Members
Latest Member: piset
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Adding a search parameter  (Read 2197 times)
Availor

Offline Offline

Posts: 225



« on: June 16, 2008, 08:07:20 PM »

Maybe someone can take it from all you coders out there....

When you perform a search you can search for a word. Exact word or part of it in the advanced search.
The idea is to let you choose two options. That "what" and the "where" function. There is a news search module that enables you to search within the news.
http://slink2.no-ip.info:82/wsb/pages/wb-ideas/test-pages/news-search.php
It would be useful to combine this, by choosing the group id for example, with the main search.

This is very useful for classifieds sites, area news (searching for "what" and "where" - each news group will be assigned as a "where" - for example first category = Berlin second category = London etc...)
Logged
thorn

Offline Offline

Posts: 980


WWW
« Reply #1 on: June 21, 2008, 08:25:54 AM »

Hello,

since wb2.7 one can add an additional parameter 'search_path' into the search-formular.
There is a (yet german only) documentation here. And some (english) code-samples here.

So, all you have to do, is to add a field (e.g. radio or text) to let the user choose the search_path (the "where" in your post).

Examples:
if you have a multilingual page (de/en) you can use
Code:
<input type="radio" name="search_path" value="/de/"> deutsch<br>
<input type="radio" name="search_path" value="/en/"> english<br>
to let the user choose whether to search in the german or in the english pages.

If the page containing the news-section is called "news" (appears as http://www.example.com/pages/news.php in browser) you can use
Code:
<input type="radio" name="search_path" value="/news"> search in news<br>
<input type="radio" name="search_path" value="-/news"> search everywhere else<br>
to let the user choose wether to search in news or everywhere but not news.

thorn.
Logged

bupaje

Offline Offline

Posts: 519


WWW
« Reply #2 on: June 21, 2008, 06:28:16 PM »

That sounds interesting. Can you still search ALL/ANY/EXACT and use this parameter? Also, can you perhaps add two pages to ignore/add

Code:

value="/downloads&/links"

« Last Edit: June 21, 2008, 07:33:34 PM by bupaje » Logged

My Blog, My Site
thorn

Offline Offline

Posts: 980


WWW
« Reply #3 on: June 21, 2008, 09:45:56 PM »

Hello,

UPDATE: since wb 2.7.1 search_path is handled slightly different (SQL: "LIKE 'search_path%'" instead of "LIKE '%search_path%'"). Updated the description below accordingly.

a full form may look like this
Code:
<form name="search" action="<?php echo WB_URL.'/search/index'.PAGE_EXTENSION?>" method="get">
  <input type="text" name="string" value="search" /><br />
  <input type="submit" value="Search" /><br />
  <input type="radio" name="match" id="match_all" value="all" checked="checked" /><label for="match_all">All Words</label>
  <input type="radio" name="match" id="match_any" value="any" /><label for="match_any">Any Words</label>
  <input type="radio" name="match" id="match_exact" value="exact" /><label for="match_exact">Exact Match</label>
  <br />
  <input type="radio" name="search_path" value="/de/" checked="checked" /> deutsch<br />
  <input type="radio" name="search_path" value="/en/" checked="checked" /> english<br />
</form>

Possible values for search_path:
search_path is a path which have to match against wb_pages.link (SQL: link LIKE 'search_path%')
  • a single path that have to match (e.g. '/de/' will match /de/hilfe/intro.php and /de/impressum.php, but not /de.php or /intro/de.php.
  • a single path not to match (e.g. '-/de/' will match [link NOT LIKE '/de/%']
  • a bunch of paths to match, separated by comma (e.g. '/de/,/intro' will match [link LIKE '/de/%' OR link LIKE '/intro%']
  • a bunch of paths not to match, separated by comma (e.g. '-/en/,/intro,/impressum' will match [link NOT LIKE '/en/%' AND link NOT LIKE '/intro%' AND link NOT LIKE '/impressum%']
There is no way to mix these different variants.


Quote
value="/downloads&/links"

"/downloads,/links"
will match /downloads.php or /downloads/files.php ...
and
/links.php or /links/a-g.php ...


BTW: you can't use '.php' (e.g. '-/impressum.php', cause link doesn't contains the '.php')


Update: to make things clear
search_path value     --    matches
/en//en/intro.php
/en/en/intro.php
/endotherm.php
en/---
en---
%en/en/intro.php
/endotherm.php
/text/monuments.php
%en//en/intro.php
/de/wenden/text.php



thorn.
« Last Edit: March 28, 2010, 01:45:05 PM by thorn » Logged

bupaje

Offline Offline

Posts: 519


WWW
« Reply #4 on: June 21, 2008, 10:03:09 PM »

Excellent - thanks. Should pin this post somewhere.
Logged

My Blog, My Site
Availor

Offline Offline

Posts: 225



« Reply #5 on: June 22, 2008, 08:06:35 AM »

Thanks a lot I will check this out  grin This opens up a whole new level of possibilities!
Logged
bupaje

Offline Offline

Posts: 519


WWW
« Reply #6 on: June 22, 2008, 08:27:34 AM »

Works great for the most part. I can use it to exclude fine. I tried to limit it to pages like /pages/links it doesn't error but it returns no results.

http://stormvisions.com/search/index.php

Unrelated/related I also note that if I go to the search page directly http://stormvisions.com/search/index.php there is a search ' ' displayed.

For the record when I installed I think I may have been one error like [search_header] but everthing else was green-ok and I clicked too fast. Since it seemed ok I didn't think about it.

Regardless it is cool and I am happy with the added power.
Logged

My Blog, My Site
thorn

Offline Offline

Posts: 980


WWW
« Reply #7 on: June 22, 2008, 02:26:55 PM »

Hello,

Works great for the most part. I can use it to exclude fine. I tried to limit it to pages like /pages/links it doesn't error but it returns no results.

Did you use '/pages/links'? This can't work, because '/pages' is not part of db-field `link`.
For a URL like 'http://www.example.org/pages/help/into.php' the search_path to include should be e.g. '/help/'.


Quote
Unrelated/related I also note that if I go to the search page directly http://stormvisions.com/search/index.php there is a search ' ' displayed.

Oh, there is really a bug. It will perform a search for 'unset'.


thorn.
Logged

bupaje

Offline Offline

Posts: 519


WWW
« Reply #8 on: June 22, 2008, 04:26:59 PM »

Shouldn't work but did. Here is what I had in the value parameter

-/help/google-tag-cloud,/help/storm-tag-cloud,/help/blog,/help/map,/help/faq,/help/about

of course -/help/ is much neater. I must have done something worng the first time, because I tried it but it didn't work. I did it again now and it did.

Anyway - thank you. I will have some more fun with the search engine later. Smiley
Logged

My Blog, My Site
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!