phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

excluding topics from search


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Tue Jan 24, 2012 9:21 am 
Post subject: excluding topics from search

Hi
I know i have seen a mod that could let moderators mark topics(or posts?) as excluded from serching. This could be very good for keeping the search tables small and dont make the search messy with unwanted bullshit. Does anyone have a link or file on their HD? I might have seen this along with the "gaia huge forums thread" but cant find it now.

One thing is to keep the tables as small as possible. Thats the most important. But i also see other smart uses. When you dont want posts to show up as (new the last 24h) this could also work here? Sometimes i dont want to delete or move a post and start a big discussion but just make it "read" or "old" right away so it dont shows up everywhere. Last post, newsletter, rss aso.. Giving these powers to my moderators would be so awesome and good for cleaning up our forums and dont make fights. :p

I found a blogpost on a similar topic on the Doctors blog. http://www.phpbbdoctor.com/blog/2007/08/12/another-search-tweak-marking-topics-unsearchable/
He is on to it but i cant find the mod now. Im shure i downloaded it and even tested it years ago but i cant find it. Anyone? Similar solutions?

Thanks!
Thomas
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Tue Jan 24, 2012 9:46 am 
Post subject: Re: excluding topics from search

Have a look at this MOD, is this what you ask for?
Code:
##############################################################
## MOD Title: Disable Search Indexing
## MOD Author: Albosky < albosky at comcast.net > (Peter Murphy) http://forum.tip.it
## MOD Description: This mod enables you to selectively turn off posts from being indexed in the search tables on a per forum basis.
## MOD Version: 1.0.0
##
## Installation Level: (Intermediate)
## Installation Time: ~20 Minutes (1 minute with EasyMOD)
## Files To Edit:
            includes/functions_post.php,
##        modcp.php
##        posting.php
##      admin/admin_forums.php
##      language/lang_english/lang_admin.php
##      templates/subSilver/admin/forum_edit_body.tpl
## Included Files: (n/a)
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
##############################################################
## MOD History:
##
##   2006-09-01 - Version 1.0.0
##      - Initial release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL ]------------------------------------------
# Change the prefix 'phpbb_' accordingly. 'phpbb_' is the default prefix
#
ALTER TABLE phpbb_forums ADD enable_form TINYINT( 1 ) DEFAULT '0' NOT NULL;

#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
   $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
#
#-----[ IN-LINE FIND ]------------------------------------------
#
f.forum_topics
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, f.index_posts
#
#-----[ FIND ]------------------------------------------
#
   $forum_id = $topic_row['forum_id'];
   $forum_name = $topic_row['forum_name'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
   $index_posts = $topic_row['index_posts'];
#
#-----[ FIND ]------------------------------------------
#
   $sql = "SELECT forum_name, forum_topics
#
#-----[ IN-LINE FIND ]------------------------------------------
#
forum_topics
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, index_posts
#
#-----[ FIND ]------------------------------------------
#
   $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
   $forum_name = $topic_row['forum_name'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
   $index_posts = $topic_row['index_posts'];
#
#-----[ FIND ]------------------------------------------
#
            remove_search_post($post_id_sql);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
            if ($index_posts)
            {
#
#-----[ FIND ]------------------------------------------
#
         }

         if ( $vote_id_sql != '' )
#
#-----[ BEFORE, ADD ]------------------------------------------
#
            }
#
#-----[ FIND ]------------------------------------------
#
         $new_forum_id = intval($HTTP_POST_VARS['new_forum']);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
         include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
         $post_id_sql = '';
#
#-----[ FIND ]------------------------------------------
#
         $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
#
#-----[ IN-LINE FIND ]------------------------------------------
#
forum_id
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, index_posts
#
#-----[ FIND ]------------------------------------------
#
            message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
         }
#
#-----[ AFTER, ADD ]------------------------------------------
#
         $forum_row = $db->sql_fetchrow($result);
#
#-----[ FIND ]------------------------------------------
#
         if (!$db->sql_fetchrow($result))
         {
            message_die(GENERAL_MESSAGE, 'New forum does not exist');
         }
#
#-----[ REPLACE WITH ]------------------------------------------
#
         if (!$forum_row)
         {
            message_die(GENERAL_MESSAGE, 'New forum does not exist');
         }
#
#-----[ FIND ]------------------------------------------
#
         $db->sql_freeresult($result);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
         $index_posts = $forum_row['index_posts'];


#
#-----[ FIND ]------------------------------------------
#
         if ( $new_forum_id != $old_forum_id )
#
#-----[ BEFORE, ADD ]------------------------------------------
#
         $sql = 'SELECT index_posts FROM ' . FORUMS_TABLE . '
            WHERE forum_id = ' . $old_forum_id;
         if ( !($result = $db->sql_query($sql)) )
         {
            message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
         }

         $forum_row = $db->sql_fetchrow($result);
         $index_post = $forum_row['index_posts'];

         $db->sql_freeresult($result);
#
#-----[ FIND ]------------------------------------------
#
               $sql = "UPDATE " . TOPICS_TABLE . "
#
#-----[ BEFORE, ADD ]------------------------------------------
#
               while ( $row2 = $db->sql_fetchrow($result) )
               {
                  $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . intval($row2['post_id']);
                  if ((!$index_post) && (index_posts))
                  {
                     $sql = "SELECT post_id, post_subject, post_text 
                        FROM " . POSTS_TEXT_TABLE . "
                        WHERE post_id = " . $row2['post_id'];
                     if ( !($result2 = $db->sql_query($sql)) )
                     {
                        message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql);
                     }
                     
                     while ( $row3 = $db->sql_fetchrow($result2) )
                     {
                         add_search_words('single', $row3['post_id'], $row3['post_text'], $row3['post_subject']);
                     }
                     $db->sql_freeresult($result2);
                  }
               }
               $db->sql_freeresult($result);
#
#-----[ FIND ]------------------------------------------
#
            // Sync the forum indexes
#
#-----[ BEFORE, ADD ]------------------------------------------
#
            if (!$index_posts)
            {
               remove_search_post($post_id_sql);
            }
#
#-----[ OPEN ]------------------------------------------
#
posting.php
#
#-----[ FIND ]------------------------------------------
#
   $forum_id = $post_info['forum_id'];
   $forum_name = $post_info['forum_name'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
   $post_index = $post_info['index_posts'];

#
#-----[ FIND ]------------------------------------------
#
submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);
#
#-----[ IN-LINE FIND ]------------------------------------------
#
$post_data
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, $post_index
#
#-----[ OPEN ]------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------
#
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, $post_username, $post_subject, $post_message, $poll_title, &$poll_options, &$poll_length)
#
#-----[ IN-LINE FIND ]------------------------------------------
#
&$post_data
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
, &$post_index
#
#-----[ FIND ]------------------------------------------
#
   add_search_words('single', $post_id, stripslashes($post_message), stripslashes($post_subject));
#
#-----[ BEFORE, ADD ]------------------------------------------
#
   if ($post_index)
   {

#
#-----[ FIND ]------------------------------------------
#
   //
   // Add poll
   //
#
#-----[ BEFORE, ADD ]------------------------------------------
#
   }

#
#-----[ OPEN ]------------------------------------------
#
admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------
#
            'S_INDEX_POSTS' => ( isset($row) && isset($row['index_posts']) && ($row['index_posts'] == 0) ) ? '' : 'checked="checked"',
#
#-----[ AFTER, ADD ]------------------------------------------
#
            'S_FORM_ENABLE' => ( isset($row) && isset($row['enable_form']) && ($row['enable_form'] == 0) ) ? '' : 'checked="checked"',
#
#-----[ FIND ]------------------------------------------
#
            'L_INDEX_POSTS' => $lang['index_posts'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
            'L_FORM_ENABLE' => $lang['enable_form'],
#
#-----[ FIND ]------------------------------------------
#
prune_enable" . $field_sql
#
#-----[ IN-LINE FIND ]------------------------------------------
#
, index_posts
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
# (before the " )
#
, enable_form

#
#-----[ FIND ]------------------------------------------
#
intval($HTTP_POST_VARS['prune_enable']) . $value_sql
#
#-----[ IN-LINE FIND ]------------------------------------------
#
. ", " . intval($HTTP_POST_VARS['index_posts'])
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
# (before the . )
#
. ", " . intval($HTTP_POST_VARS['enable_form'])
#
#-----[ FIND ]------------------------------------------
#
, index_posts = " . intval($HTTP_POST_VARS['index_posts']) . "
#
#-----[ AFTER, ADD ]------------------------------------------
#
, enable_form = " . intval($HTTP_POST_VARS['enable_form']) . "
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
$lang['index_posts'] = 'Index posts for searching';
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['enable_form'] = 'Mostrar formulario';
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/forum_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
   <tr>
     <td class="row1">{L_INDEX_POSTS}</td>
     <td class="row2">{L_ENABLED}<input type="checkbox" name="index_posts" value="1" {S_INDEX_POSTS} /></td>
   </tr>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
   <tr>
     <td class="row1">{L_ENABLE_FORM}</td>
     <td class="row2">{L__ENABLED}<input type="checkbox" name="enable_form" value="1" {S_ENABLE_FORM} /></td>
   </tr>
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM


P.d.: I tried attaching it as a .zip but for some unknown reason I can not attach it, the same happened a few weeks ago. There seems to be a problem.

_________________
phpBB2 will never die, I hope!
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Tue Jan 24, 2012 9:58 am 
Post subject: Re: excluding topics from search

Yes yes! This must be it! icon_biggrin.gif Thanks that was quick. icon_biggrin.gif
Ok no problem. Just copy/pasted it over to a fresh file here now. icon_smile.gif
Thanks
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Tue Jan 24, 2012 10:10 am 
Post subject: Re: excluding topics from search

Good! icon_smile.gif
_________________
phpBB2 will never die, I hope!
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Wed Jan 25, 2012 7:31 pm 
Post subject: Re: excluding topics from search

The MOD itself is fairly simple. There is a check to see if the topic is searchable or not and then you skip the block of code that inserts the words into the search word tables, and that's about it. You have to be able to rebuild the search for the entire topic if the flag changes. I don't know if I ever wrote it up (the one mentioned on my blog).
_________________
phpBBDoctor Blog
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Wed Feb 22, 2012 9:10 pm 
Post subject: Re: excluding topics from search

I have some troubble with this one it seems. When i have to move posts.

In modcp.php(the mod here shows viewforum.php for some reason) i have
Code:
$sql = "UPDATE " . TOPICS_TABLE . "
2 times. Can somebody with a working file let me know how it looks like i would really appretiate it. icon_smile.gif I cant move posts anymore with this installed it seems. :/ I just get the "New forum does not exist" so i guess i must remove it again from that section of the code.

I also added the fixes from here: http://www.phpbb.com/community/viewtopic.php?t=437646

Other than the move issue it seems to be working. The rebuilding and selecting forums in acp.


edit: seems like the "$db->sql_freeresult($result);" also is repeated about 10 times in modcp.php hmm..

edit2: wow had to disable it now. We have so much troubble with it. Didnt understand until now that this caused them all. Now when i uploaded the backupfiles everything works again. Hope somebody have the time to look over the mod sometime. I will gladly pay the person who upgrades this to the last phpbb2 version. icon_wink.gif

Doctor: Can you contact me when you accept new work? I want to start a new project and i think you can do it.
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Mon Feb 27, 2012 3:06 pm 
Post subject: Re: excluding topics from search

It seems to work now after a big round with trying and testing. icon_smile.gif
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Thu Mar 08, 2012 1:59 am 
Post subject: Re: excluding topics from search

When installing a MOD, the find target is the first match that you find from the position of the last edit. So it's not really a problem if you find the target more than once, just make sure you start from the right place and find the next instance of the target text.
_________________
phpBBDoctor Blog
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Thu Mar 08, 2012 3:39 pm 
Post subject: Re: excluding topics from search

Ok thanks for the tip. I thought so but for some reason i got alot of bugs on my live site. My modcp file is modified so i was expecting some troubble. But not that much. icon_smile.gif And of course i might have done something wrong.

But that didnt solve my first goal of removing some topics from the searching. They still show up even after deselecting the forums and rebuilding. My search tables went from 150mb to 50 so it is working as it should(?). Anyhoo I found this now on phpbbhacks. I think this is it. icon_smile.gif
http://www.phpbbhacks.com/forums/excluding-specific-forums-from-view-posts-since-last-v-vt29838.html

Code:
by Thoul
Find this line in search.php:
Code:  Select
         $ignore_forum_sql = '';


Change it to this:
Code:  Select Contract
         if( $search_id == 'newposts' )
         {
            $ignore_forum_sql = '1,2,3';
         }
         else
         {
            $ignore_forum_sql = '';
         }


Change the "1,2,3" to a comma separated list of the forums that should be left out of the list.


Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Thu Mar 08, 2012 9:16 pm 
Post subject: Re: excluding topics from search

The "New Posts" search has nothing to do with the size of the search index tables. The search index tables are used only when a keyword search is done. The code you posted will work, but it's a completely different functionality.
_________________
phpBBDoctor Blog
Back to top
hoimyr
Board Member



Joined: 16 Apr 2009

Posts: 115
Location: Oslo


flag
PostPosted: Thu Mar 08, 2012 10:33 pm 
Post subject: Re: excluding topics from search

Yes i know. I thought the Disable Search Indexing mod excluded forums from both the "new post" and searching. icon_rolleyes.gif But yes i know now that i have to do that hardcoded trick.
I have read alot on your blog about searching. Very interesting reading!
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0148 seconds using 15 queries. (SQL 0.0024 Parse 0.0003 Other 0.0120)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo