Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 07:36:52 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.
155526 Posts in 21713 Topics by 7736 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: search and languages  (Read 1843 times)
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« on: July 18, 2009, 02:43:53 PM »

can a search function be made something like this:

if page language from which I searc = en,
 then search function shuld search only in the pages with that (en) language ?

cheers
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7973



WWW
« Reply #1 on: July 18, 2009, 03:00:58 PM »

Hello,

yes this is possible. there exist a few non dokumented parameters in search from thorn with wich you can realize this. didn't find the post where it is described, maybe ask thorn.

Matthias

Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #2 on: July 18, 2009, 03:22:49 PM »

i searched the forum but couldnt find it.. but i think I saw it somewhere too Smiley)

thorn, help Smiley)
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7973



WWW
« Reply #3 on: July 18, 2009, 04:02:54 PM »

Hello,

in German, but the posted code should help you:

http://www.websitebaker2.org/forum/index.php/topic,12141.msg73707.html#msg73707

But there exists another thing too, i know  huh

Matthias
Logged
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #4 on: July 18, 2009, 09:13:34 PM »

Code:
// looks in modules/module/ and modules/module_searchext/
...
$query = $database->query("SELECT DISTINCT directory FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND directory NOT LIKE '%_searchext' AND LANGUAGE = $search_lang ");


This is from search.php file.. I think it should look like something like this but unfortunately, not working Smiley

I hope I am on the right path Smiley
« Last Edit: July 18, 2009, 09:26:15 PM by crnogorac081 » Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
thorn

Offline Offline

Posts: 980


WWW
« Reply #5 on: July 18, 2009, 10:23:17 PM »

Hello,

all you have to do is to add the "search_path" parameter to your search query, i.e. http://localhost/search/index.php?search_path=/en/&string=searchstring.

http://www.websitebaker2.org/forum/index.php/topic,12141.msg73707.html#msg73707
shows how to add a customised search-form to your template.

See also http://www.websitebaker2.org/forum/index.php/topic,10058.msg59467.html#msg59467


thorn.
Logged

crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #6 on: July 19, 2009, 12:03:18 AM »

Yes, I saw that, but that is if you have site structure like www.localhost/en/english_pages.php and www.localhost/de/deuche_pages.php , than the path parametar determines if the search will work in /en or /de folder, am I correct ?


I used easy miltilanguage snipet, and there I dont have /en and /de folders.. All pages are in menu's root..

for eg.

Page-1 -- page language is EN
Page-2 -- page language is EN

Seite-1 -- page language is DE
Seite-2 -- page language is DE

Now, if I am on page 1 - which has LANGUAGE; = EN, search function should search only in pages which have ?lang=EN at the end of url , like: www.localhost/pages/page-1.php?lang=EN  and not in  www.localhost/pages/seite-1.php?lang=DE
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
thorn

Offline Offline

Posts: 980


WWW
« Reply #7 on: July 19, 2009, 01:26:09 AM »

Hello,

Quote
I used easy miltilanguage snipet, and there I dont have /en and /de folders.. All pages are in menu's root..

yes, you are right. In this case search_path is not what you are looking for.
But as far as i know the LANG parameter is present only while changing from one language to another, isn't it?.
In your case, the language is set in table pages, column language.

Try this (untested): EDIT: Do not use this code! See here for a better solution.

Add a new parameter to the search-form in your Template.
Code: (Template)
<?php
    
if(SHOW_SEARCH) {
        global 
$wb;
        if(isset(
$wb->page['language']))
          
$search_lang $wb->page['language'];
        elseif(isset(
$_REQUEST['search_lang']))
          
$search_lang addslashes(htmlspecialchars($wb->strip_slashes($_REQUEST['search_lang']), ENT_QUOTES));
        else
          
$search_lang '';
?>

<form name="search" action="<?php echo WB_URL.'/search/index'.PAGE_EXTENSION?>" method="post">
<h2><?php echo $TEXT['SEARCH']; ?></h2>  
<input type="hidden" name="search_lang" value="<?php echo $search_lang ?>">
<input type="text" name="string" /><br /><br />
<input type="submit" name="submit" value="<?php if(isset($TEXT['SUBMIT'])) { echo $TEXT['SEARCH']; } else { echo 'Search'; } ?>" />
</form>
<?php }
?>


Change the file search/search.php (around line 340) [ignore the <?php-markers]:
Code: (Original)
<?php
$sections_query 
$database->query("
    SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end,
           p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by,
           p.visibility, p.viewing_groups, p.viewing_users
    FROM 
$table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id
    WHERE s.module = '
$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL
    ORDER BY s.section_id, s.position ASC
"
);
Code: (Changed)
<?php
if(isset($_REQUEST['search_lang'])) {
  
$search_lang addslashes(htmlspecialchars($wb->strip_slashes($_REQUEST['search_path']), ENT_QUOTES));
  
$search_lang_sql "p.language = '$search_lang' AND";
} else
  
$search_lang_sql '';
$sections_query $database->query("
    SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end,
           p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by,
           p.visibility, p.viewing_groups, p.viewing_users
    FROM 
$table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id
    WHERE 
$search_lang_sql s.module = '$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL
    ORDER BY s.section_id, s.position ASC
"
);

You have to change the search-form on the search-page itself, too (in advanced options).
But first check if the above changes work as expected.


thorn.
« Last Edit: July 19, 2009, 09:17:47 PM by thorn » Logged

crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #8 on: July 19, 2009, 06:39:57 PM »

Hi thorn,

the code didn't work at first, but with some playing i managed to make it work Smiley, at least a part of it.

Here is modifications of your code:


Code: (Template)
<?php
    
if(SHOW_SEARCH) {
        global 
$wb;
        if(isset(
$wb->page['language']))
          
$search_lang $wb->page['language'];
        elseif(isset(
$_REQUEST['search_lang']))
          
$search_lang addslashes(htmlspecialchars($wb->strip_slashes($_REQUEST['search_lang']), ENT_QUOTES));
        else
          
$search_lang '';
?>

<form name="search" action="<?php echo WB_URL.'/search/index'.PAGE_EXTENSION?>" method="post">
<h2><?php echo $TEXT['SEARCH']; ?></h2>   
<input type="hidden" name="search_lang" value="<?php echo $search_lang ?>">
<input type="text" name="string" /><br /><br />
<input type="submit" name="submit" value="<?php if(isset($TEXT['SUBMIT'])) { echo $TEXT['SEARCH']; } else { echo 'Search'; } ?>" />
</form>
<?php }
?>


Thiw was not required to do, the search can stay as it is. Also in Advanced search options, nothing is required to change.

In this part:

Code: (Original search/search.php)
<?php
$sections_query 
$database->query("
    SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end,
           p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by,
           p.visibility, p.viewing_groups, p.viewing_users
    FROM 
$table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id
    WHERE s.module = '
$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL
    ORDER BY s.section_id, s.position ASC
"
);
Code: (Changed)
<?php
if(isset($_REQUEST['search_lang'])) {
  
$search_lang addslashes(htmlspecialchars($wb->strip_slashes($_REQUEST['search_path']), ENT_QUOTES));
  
$search_lang_sql "p.language = '$search_lang' AND";
} else
  
$search_lang_sql '';
$sections_query $database->query("
    SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end,
           p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by,
           p.visibility, p.viewing_groups, p.viewing_users
    FROM 
$table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id
    WHERE 
$search_lang_sql s.module = '$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL
    ORDER BY s.section_id, s.position ASC
"
);

this code made it work:
Code: (Which worked)
$search_lang_sql = "p.language = '$search_lang' AND";

$sections_query = $database->query("
    SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end,
           p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by,
           p.visibility, p.viewing_groups, p.viewing_users
    FROM $table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id
    WHERE $search_lang_sql s.module = '$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL
    ORDER BY s.section_id, s.position ASC
");

It works now, but if you search a whole word. For example if you type: english , and have word "english" in pages on EN and DE, the search result will show only page on one language. But if you type only "eng" , it will show pages in both languages..

Also I think this should be added in the next release of WB, maybe 2.9 , if you choose Page Languages, in search options to choose if you want this seach filtered by language or not..

cheers

p.s.: thorn, you are a god Smiley
« Last Edit: July 19, 2009, 06:52:33 PM by crnogorac081 » Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
thorn

Offline Offline

Posts: 980


WWW
« Reply #9 on: July 19, 2009, 09:16:44 PM »

Hallo,

da habe ich tatsächlich zu umständlich gedacht  rolleyes

Die benutzte Anzeigesprache wird tatsächlich in LANGUAGE mitgeschleppt, auch auf der Seite mit den Suchergebnissen, die ja bekanntlich keine echte Seite darstellt [keine page_id hat].

Folglich reicht das hier (Datei search.php):
Code: (Original bei ca. Zeile 340)
$sections_query = $database->query("
    SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end,
           p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by,
           p.visibility, p.viewing_groups, p.viewing_users
    FROM $table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id
    WHERE s.module = '$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL
    ORDER BY s.section_id, s.position ASC
");
Code: (geändert)
$search_language_sql = "p.language = '".LANGUAGE."' AND";
$sections_query = $database->query("
    SELECT s.section_id, s.page_id, s.module, s.publ_start, s.publ_end,
           p.page_title, p.menu_title, p.link, p.description, p.keywords, p.modified_when, p.modified_by,
           p.visibility, p.viewing_groups, p.viewing_users
    FROM $table_s AS s INNER JOIN $table_p AS p ON s.page_id = p.page_id
    WHERE $search_language_sql s.module = '$module_name' AND p.visibility NOT IN ('none','deleted') AND p.searching = '1' $search_path_SQL
    ORDER BY s.section_id, s.position ASC
");

und nochmal etwas tiefer
Code: (Original bei ca. Zeile 430)
$query_pages = $database->query("
    SELECT page_id, page_title, menu_title, link, description, keywords, modified_when, modified_by,
           visibility, viewing_groups, viewing_users
    FROM $table
    WHERE visibility NOT IN ('none','deleted') AND searching = '1' $search_path_SQL
");
Code: (geändert)
$search_language_sql = "language = '".LANGUAGE."' AND";
$query_pages = $database->query("
    SELECT page_id, page_title, menu_title, link, description, keywords, modified_when, modified_by,
           visibility, viewing_groups, viewing_users
    FROM $table
    WHERE $search_language_sql visibility NOT IN ('none','deleted') AND searching = '1' $search_path_SQL
");

Bevor man das aber generell in WB übernimmt, müßte man sich nochmal überlegen ob man das immer so haben will, oder nur wenn "Seitensprache" eingeschaltet ist. Denn dann müßte man noch gegen PAGE_LANGUAGES prüfen.


thorn.
« Last Edit: July 24, 2009, 04:15:40 PM by thorn » Logged

crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #10 on: July 19, 2009, 09:45:36 PM »

Hi Thorn,

I dont know a bit of german, but I followed the code, and when I add extra parametar in line ~430:

$search_language_sql = "p.language = '".LANGUAGE."' AND";
$query_pages = $database->query("
    SELECT page_id, page_title, menu_title, link, description, keywords, modified_when, modified_by,
           visibility, viewing_groups, viewing_users
    FROM $table
    WHERE $search_language_sql visibility NOT IN ('none','deleted') AND searching = '1' $search_path_SQL
");

The page design and content breaks below search result.. And when I remove $search_language_sql  from WHERE line , page doesnt break..

wierd... huh

----- Update:

Just turned on error reporting and I got this: Fatal error: Call to a member function numRows() on a non-object in I:\WebsiteBaker Portable1_2\htdocs\wb2\search\search.php on line 454

and that line is:
Code:
   $search_language_sql = "p.language = '".LANGUAGE."' AND";
    $query_pages = $database->query("
        SELECT page_id, page_title, menu_title, link, description, keywords, modified_when, modified_by,
               visibility, viewing_groups, viewing_users
        FROM $table
        WHERE $search_language_sql visibility NOT IN ('none','deleted') AND searching = '1' $search_path_SQL
    ");
    if($query_pages->numRows() > 0) {     ------------------ THIS IS LINE 454
« Last Edit: July 19, 2009, 10:00:16 PM by crnogorac081 » Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
thorn

Offline Offline

Posts: 980


WWW
« Reply #11 on: July 19, 2009, 10:25:40 PM »

I dont know a bit of german, but I followed the code,
Oh sorry, in time of writing i didn't realise that this is an English-speaking thread...

Quote
Just turned on error reporting and I got this: Fatal error: Call to a member function numRows() on a non-object in I:\WebsiteBaker Portable1_2\htdocs\wb2\search\search.php on line 454
Ah, my fault! An copy-n-paste issue  rolleyes
On line ~430 p.language has to be language
Code:
$search_language_sql = "language = '".LANGUAGE."' AND";
EDIT: this is fixed in the above example.

Absent-minded greetings
thorn.
« Last Edit: July 24, 2009, 04:16:17 PM by thorn » Logged

crnogorac081
AddOn Development
*
Offline Offline

Posts: 1706



« Reply #12 on: July 19, 2009, 10:55:35 PM »

Thorn,

It works like a charm !

Code:
Oh sorry, in time of writing i didn't realise that this is an English-speaking thread...

Now all people who speaks deuche can see this.

In combination with Snippet: Easy Multilanguage Link ( http://www.websitebaker2.org/forum/index.php/topic,14037.0.html ) , WB is very powerfull tool for multilanguage sites.

cheers
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
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!