(almost) Perfect Search

Download plugins, language packs and stuff.

(almost) Perfect Search

Postby scottdallas » Tue Dec 09, 2008 9:10 am

This isn't a plugin but if you apply these changes to your cutenews.ru installation your search bar will function better. One early problem with cnr was that you could not search multiple words. FI-DD has solved this, it has been applied in these files. Another problem that arose was the fact you could not get search pagination to work properly. I solved this by manipulating a few files so when search.php accesses for /inc/show.news.php (the file that modifies the pagination links) it will be rerouted through it's includes into the file /inc/show.search.php instead. The file show.news.php was preserved. When normal pagination occurs it will still reference /inc/show.news.php but when search.php access the pagination rules.. you see.. /inc/show.search.php rules apply.

Installation:
You'll need to preserve the file paths to ensure it will all work properly. Other than that just overwrite and add the files to your current Cutenews.ru :)

You can see it working/functioning properly at www.scodal.com and www.scodal.com/search.php (search something like 'the' and that'll bring up more than 10 results) Also, I've included the blank file /data/search-history.txt because without it you'll automatically get an error when you try to use search-history and there's just no reason for that when the problem is fixed regardless with a 0 byte file.

I feel like more than me writing a new plugin or addon to cutenews.ru I've merely used the existing code and helped to finish something that should have been done long ago. My apologies for not figuring this out sooner. It seems to so clear to me now lol

Fixing the error if you get one...
Download & activate the search history plugin

Okay, enjoy!

What I wish search could do in the future:
Image A cool search dropdown using search-history. Can it be done FI-DD?
Attachments
almost.perfect.search.zip
(10.19 KiB) Downloaded 184 times
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby azn_romeo_4u » Wed Dec 10, 2008 5:18 am

Nice but there's still that problem of it adding search&search=thedo=search& over and over again over multple pages. Never the less I'll be using this on my site. Thx man =D
azn_romeo_4u
 
Posts: 123
Joined: Thu Sep 18, 2008 5:06 am

Postby scottdallas » Thu Dec 11, 2008 5:38 am

oh wow you're right each page the search URL gets longer and longer. maybe that's cause of the way i have the links generate in show.search.php, i'll have to take another look. at least it functions but you're right it can't stay like that.
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby azn_romeo_4u » Fri Dec 12, 2008 5:23 am

I think it has to be like that though man, because it's a "get" method and not a post method. So there's no way for the script to know what it's fetching i think if the url doesn't stay like that unless you create some kind of session or memory so it stores all the search results. No clue what i'm talking about, but I think you understand.
azn_romeo_4u
 
Posts: 123
Joined: Thu Sep 18, 2008 5:06 am

Postby scottdallas » Fri Dec 12, 2008 8:08 am

haha i get you yeah it's past my knowledge at this point. at least it's working.. at least people will copy and paste content URL's more than search result pages.
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby azn_romeo_4u » Fri Dec 19, 2008 7:45 am

Here's a tip for security (original by fi-dd)

In search.php

Find: (line 94 in the above download)
Code: Select all
global $search_boolean, $search, $sql;


Add Below:
Code: Select all
if(strlen($search) > 2){


Find: (line 121 in the above download)
Code: Select all
      $select[] = $row['id'];
   }


Replace with:
Code: Select all
      $select[] = $row['id'];
   }
}
else{echo "<br clear=\"all\"><center><h1>Word is too short.</h1></center>";}


Chage the #2 to whatever you want. It will only search for words that is greater than 2 letters, so it will search for words with 3 letters. IMO i would set to greater 3. Depending on your site, but on my site have people searching for stuff like dog and cat so i have to keep it at 2.

Also I only allow title searchs and not full or short story.
azn_romeo_4u
 
Posts: 123
Joined: Thu Sep 18, 2008 5:06 am

Postby webbber » Sun Dec 21, 2008 1:14 am

Watch out with search engines. take security tips.
webbber
 
Posts: 155
Joined: Thu May 15, 2008 1:13 am

Postby nolikewise » Sun Dec 21, 2008 11:15 am

This works faster than the original one, but i couldnt get search pagination. Is there anything else i should add to search.tpl?

By the way you can get rid of search history stuff by deleting

//Search history start

code
code
code
codecode

//search history ends

in search.php



You can check, pagination does not work on my site. Type; english, tense, etc.
You'll see there is no pagination... http://www.okuogren.com/haber.php/search
nolikewise
 
Posts: 177
Joined: Mon Dec 17, 2007 8:47 am
Location: Turkiye

Postby nolikewise » Mon Dec 22, 2008 9:34 pm

Okay I got it work, thanks to RAMON...

dont forget to add $number = 10; in search.php above or below $template = 'Search'; and $template = 'Default';
nolikewise
 
Posts: 177
Joined: Mon Dec 17, 2007 8:47 am
Location: Turkiye

Postby scottdallas » Tue Dec 23, 2008 10:06 pm

oh and you're supposed to set the template in search.php not in your include code. I know that's weird and not like the usual show_news.php but that's how this one was set up.
Last edited by scottdallas on Sun Apr 26, 2009 7:08 am, edited 1 time in total.
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby nam » Fri Jan 02, 2009 4:56 pm

azn_romeo_4u wrote:Replace with:
Code: Select all
      $select[] = $row['id'];
   }
}
else{echo "<br clear="all"><center><h1>Word is too short.</h1></center>";}



I suggest you to add this piece of code to show the number of searched results:

Code: Select all
echo 'Search returned <b>'.count($select).'</b> results.';


Here is how it should look:

Code: Select all
   else{echo "<br clear="all">Word is too short. <br/>";}

   if ($select){
      $where[] = 'id = '.(count($select) > 1 ? '['.join('|', $select).']' : join('', $select));
      $where[] = 'and';
   } else {
      $where = array('id = 0', 'and');
   }

echo 'Search returned <b>'.count($select).'</b> results.';
echo '<br/><br/>';
return $where;
}
User avatar
nam
 
Posts: 221
Joined: Sat Dec 23, 2006 9:10 pm

Postby mark99 » Wed Feb 25, 2009 6:22 pm

That code mod to show the number of results doesn't seem to work, sometimes it does but others I've had 1 or 2 results and yet both times it would count 3.

Also, how can I get the old date period search selection stuff back and working from the original search? I liked the ability to search news by date periods or category. However if I remove style="display: none" from the related TR's then the forms show but the search doesn't appear to factor them in (selecting a specific date makes no difference).
mark99
 
Posts: 123
Joined: Mon Feb 09, 2009 6:01 pm

Postby mark99 » Sun Mar 01, 2009 5:18 pm

Imposing a time limit would also help security, so that somebody can't make more than 3 searches within a 30 second period.
mark99
 
Posts: 123
Joined: Mon Feb 09, 2009 6:01 pm

Postby mark99 » Sat Apr 25, 2009 2:41 pm

I wanted to update my news system with the latest April 2009 update to the main CNRU package, which makes some changes to the /inc/show.news.php file. Could you either update this add-on with the latest show.news.php file or say what file changes are needed to work with your search mod?
mark99
 
Posts: 123
Joined: Mon Feb 09, 2009 6:01 pm

Postby scottdallas » Sun Apr 26, 2009 7:10 am

What's different with these files in the latest download? As far as I know these would be the most recommended files to use with your CNR. I use them currently with no flaws for me or my visitors so I'd assume overwrite with these files still unless there is a major difference or reason that I'm unaware of.

FI-DD? Help me out here lol
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Next

Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron