View Full Version : mod - search engine
thomas
10-13-2005, 07:06 AM
Ive was using the seach engine, and suddenly realised that it includes offline articles in the search??
So ive looked in the code, and there was no where in the sql statements that require the article to be on or off, and i cant work out how to include activated = 1 into the following sql statement
$getarticles = $DB->query("SELECT categoryid, articleid, title, datecreated FROM " . TABLE_PREFIX . "p2_news
WHERE $searchby LIKE '%".$searchtext."%'
ORDER BY datecreated DESC
LIMIT $start, " . ($limit + 1) . "");
so somewhere, and ive tried placing it in a few places, you need to say that "activated = 1"
anyone?
abcohen
10-13-2005, 03:13 PM
nice catch... I'll let them know.
abcohen
10-14-2005, 01:59 AM
Tomato_Dance says:
WHERE $searchby LIKE '%".$searchtext."%' AND activated = '1'
thanks TD :)
thomas
10-14-2005, 02:56 AM
i dont think that works, sorry...
the column is not called activated i dont think. i will look thou. thansk anyhow
thomas
10-14-2005, 04:39 AM
fixed.
solution here
http://www.subdreamermods.com/forum/showth...p=3083#post3083 (http://www.subdreamermods.com/forum/showthread.php?p=3083#post3083)
labrekke
10-14-2005, 01:06 PM
As I told Thomas in the support ticket he made:
In Subdreamer 2.0 we started using an array of bit fields for the settings of articles. The values of the news settings can be found on line 19-29 in the file plugins/p2_news/news.php. To figure out if a news article is online or not, you need to check if the bitfield value "2" is a part of the field SETTINGS in the table P2_NEWS. On line 69-71 in the same file, you will see how the online setting is checked.
This is something that clearly needs to be fixed in the search plugin, so here goes:
On line 26-28 in the file plugins/p23_search_engine/search_engine.php you will find this code:
$getarticles = $DB->query("SELECT categoryid, articleid, title FROM " . TABLE_PREFIX . "p2_news
WHERE $searchby LIKE '%".$searchtext."%'
LIMIT $start, " . ($limit + 1) . "");
Replace it with this:
$getarticles = $DB->query("SELECT categoryid, articleid, title FROM " . TABLE_PREFIX . "p2_news
WHERE (settings & 2) AND $searchby LIKE '%".$searchtext."%'
LIMIT $start, " . ($limit + 1) . "");
As you can see, the clue is to add (settings & 2) in the select. In other words: Tomato_Dance's solution is not correct, allthough it will probably work if you use the global settings for all news articles.
abcohen
10-14-2005, 01:34 PM
TD correct him self with...
WHERE $searchby LIKE '%".$searchtext."%' AND settings >= 3
but Lab solution Works as well, but now my question becomes how do you dispaly results while searching all of your cloned news plugins too...
thomas
10-15-2005, 01:27 AM
i guess you could search for all tables that have the extension "_news" ??
labrekke
10-15-2005, 08:20 AM
You will probably have to use UNION (http://dev.mysql.com/doc/refman/5.0/en/union.html) in your SELECT sentence to get data from all news tables or rewrite the function to do as many selects as there are news tables... The output also has to be modified off course, so that URLs points to the correct articles.
thomas
10-15-2005, 08:27 AM
i guess if someone really needs to do that they would rewrite it, but it seems silly to rewrite the plugin for a select few. but i dunno.
think it needs to go onto the to do list.
thanks labreke
Plugin has been updated on SD.com
http://www.subdreamer.com/sd_plugins/p13_s...3/p13_fileid/19 (http://www.subdreamer.com/sd_plugins/p13_sectionid/3/p13_fileid/19)
tokenyank
10-25-2005, 02:18 PM
I know this may be a stupid question, but does this only index the site or does it index the forums as well?
Terminator1138
10-25-2005, 06:12 PM
I don't think so since there is a seperate search feature for that, perhaps integration maybe?
it also depends on what search feature or plugin you are using, just a guess
thomas
10-25-2005, 11:38 PM
the search engine plugin ONLY searches through the NEWS plugin, i hope that clears things up
tokenyank
10-26-2005, 11:55 PM
It does indeed... Thank you thomas won't be installing that then! :D
If one ever comes out that indexes both the SD site and the forum integration, I'd be there...
Though, that said, I've used 3rd party indexers in the past and my forums blow the database up by several hundred mb... So, on 2nd thought, perhaps this wouldn't be a 'great' idea after all! :D
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.