Search Focus Dropdown

Started by Brettflan, February 14, 2009, 02:34:48 PM

Previous topic - Next topic

TLMB

#320
Hi,
First of all, thank you for this mod. I've been using it for a while now (1.52). I just upgraded to 1.61 to try to fix something I'd discovered, but with no luck....

It seems like an apostrophe ' in the middle of the search term will break the search.

e.g. There is a post on my forum which contains the phrase
monkey's chair

Searching for
monkey chair
or
monkey
or
'monkey'
will find it, but if I search for
monkey's chair
or
monkey's
then no results are shown.

I don't know if this is a problem with the search itself, or with this mod. Sorry if this has been answered elsewhere, but I tried searching this thread for "apostrophe", and also googling, but didn't find a solution.
I'm on SMF 2.0.6.

Thanks for any replies.

Brettflan

That problem would be unrelated to this mod package; the search terms and index method aren't affected by it. It sounds like a problem with the search index method you're using not properly sanitizing the search string. I seem to recall there were some bugs with the Sphinx search method a few years back along those lines, but that has long since been fixed.
I use this mod on a few forums and a Sphinx index as well on a particularly large one (~6M posts), and I don't have your problem on any of them.

TLMB

Okay, thanks for letting me know.

iain sherriff

I see you have commented on this before
I am getting a lot of errors in the log

Apply Filter: Only show the error messages of this URL
http://***/index.php?topic=6293.125;topicseen
Apply Filter: Only show the errors with the same message
8: Undefined index: search_scope_board
Apply Filter: Only show the errors from this file
File: /home2/turbopb1/public_html/***/Themes/default/languages/SearchFocus.english.php (body_above sub template - eval?)
Line: 278


and the same but line 277 and line 279

The search is working fine and the error has no effect that I can see on forum operation. the file look as it does if I parse the mod files on here.

A way to stop the log filling up would be good, just wondering if anything I have posted here is a clue for you  :)

Thanks
SMF 2.0.12

Brettflan

Quote from: iain sherriff on December 31, 2013, 02:09:16 AM

Apply Filter: Only show the error messages of this URL
http://***/index.php?topic=6293.125;topicseen
Apply Filter: Only show the errors with the same message
8: Undefined index: search_scope_board
Apply Filter: Only show the errors from this file
File: /home2/turbopb1/public_html/***/Themes/default/languages/SearchFocus.english.php (body_above sub template - eval?)
Line: 278

Where do you have 'search_scope_board'? That's not correct for this mod, it would correctly be 'search_focus_board'. Also, the reported error isn't useful with template eval disabled; you can find that option under Admin->Configuration->Server Settings->General, as "Disable evaluation of templates". You do normally want to have that option enabled for better performance, but you should temporarily disable it to let you track down errors occurring inside templates/themes.

iain sherriff

Thanks for the answer.
" Disable evaluation of templates " was not ticked.
I have ticked it now and get

Apply Filter: Only show the error messages of this URL
http://***.com/index.php?topic=6271.100;topicseen
Apply Filter: Only show the errors with the same message
8: Undefined index: search_scope_board
Apply Filter: Only show the errors from this file
File: /home2/turbopb1/public_html/***.com/Themes/default/index.template.php
Line: 278


is there another mod that could have been installed/deleted that couldhave left behind "scope" ? Any clue were to look please ?

SMF 2.0.12

iain sherriff

from index.template.php around line 270

// Search Focus Dropdown
include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');

echo '
';

// Search Focus Dropdown
include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');

echo '
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />
<select name="search_scope">
<option value="topic" selected="selected">', $txt['search_scope_topic'], '</option>
<option value="board">', $txt['search_scope_board'], '</option>
<option value="all">', $txt['search_scope_all'], '</option>
</select>';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />
<select name="search_scope">
<option value="board" selected="selected">', $txt['search_scope_board'], '</option>
<option value="all">', $txt['search_scope_all'], '</option>
</select>';

echo '</form>';

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<h2>', $txt['news'], ': </h2>

SMF 2.0.12

Brettflan

Quote from: iain sherriff on January 01, 2014, 05:33:17 PM
from index.template.php around line 270

// Search Focus Dropdown
include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');

echo '
';

// Search Focus Dropdown
include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');

echo '
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />
<select name="search_scope">
<option value="topic" selected="selected">', $txt['search_scope_topic'], '</option>
<option value="board">', $txt['search_scope_board'], '</option>
<option value="all">', $txt['search_scope_all'], '</option>
</select>';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />
<select name="search_scope">
<option value="board" selected="selected">', $txt['search_scope_board'], '</option>
<option value="all">', $txt['search_scope_all'], '</option>
</select>';

echo '</form>';

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<h2>', $txt['news'], ': </h2>

The primary code for integration in index.template.php is this:
// Search Focus Dropdown
include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');

You appear to have that twice, which shouldn't be a problem really since it's an include_once, but only one is needed so you could remove the second copy.

Then below that you do appear to have some old code from pre-1.5 versions of this mod, which is the source of your problem. That explains the 'search_scope_board' index reference; I'd thought it sounded familiar, but I don't even have that old of a version still available in my local backups and didn't find any reference to it in the 1.5+ code backups I do have when I did a quick check earlier.

The main thing to remove there to fix your error would be the two "<select name="search_scope">...</select>" sections. That will take care of it. There's a tiny bit more extraneous code in there added by that old version of the mod which could be removed, but it won't cause any problems and I'm not completely certain which bit(s) it would be at this point. If you have an original unmodified copy of the index.template.php for your theme you could do a comparison to be sure what has been changed.

iain sherriff

That's great, thanks. Bit of a mystery but I haven't admined this board from the start.

Big help form here as always  :)
SMF 2.0.12

iain sherriff

So remove the bits in red ?

Quote// Search Focus Dropdown
      include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');

      echo '
               ';

      // Search Focus Dropdown
      include_once($settings['default_theme_dir'] . '/SearchFocus.template.php');


      echo '
               <input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
               <input type="hidden" name="advanced" value="0" />';

      // Search within current topic?
   if (!empty($context['current_topic']))
      echo '
            <input type="hidden" name="topic" value="', $context['current_topic'], '" />
            <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />
            <select name="search_scope">
               <option value="topic" selected="selected">', $txt['search_scope_topic'], '</option>
               <option value="board">', $txt['search_scope_board'], '</option>
               <option value="all">', $txt['search_scope_all'], '</option>
            </select>
';
   // If we're on a certain board, limit it to this board ;).
   elseif (!empty($context['current_board']))
      echo '
            <input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />
            <select name="search_scope">
               <option value="board" selected="selected">', $txt['search_scope_board'], '</option>
               <option value="all">', $txt['search_scope_all'], '</option>
            </select>
';

   echo '</form>';

   // Show a random news item? (or you could pick one from news_lines...)
   if (!empty($settings['enable_news']))
      echo '
            <h2>', $txt['news'], ': </h2>
SMF 2.0.12

iain sherriff

I referred to #13 and removed the relevant bits. Seems to be OK now  :)
SMF 2.0.12

Brettflan

Quote from: iain sherriff on January 03, 2014, 07:37:41 PM
I referred to #13 and removed the relevant bits. Seems to be OK now  :)
Sorry, yes, that's correct. Good to hear you sorted it out.

My internet went down and needed me to fix it, and as it happened I got really sick at the same time. Finally felt good enough to work on it and fix it today, so now I'm finally catching up.

Chas Large

Hi Brett,

Been using you mod for ages now on 2.0.xx and working very well, thank you.  :)

Two quick questions / requests.

1. Is it possible to move the "Entire Forum" item in the drop down list from the bottom to the top? Many phone users say it causes too much scrolling.

2. Is it possible NOT to show ADMIN ONLY boards in the list? I have several that only Admins and Global Mods can see but if I include these in the list, other members can see them in the drop down and try to access them, failing of course then asking what they are etc. It would be better if they were only visible to Admins and GMs.

Thanks again.

Chas.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

Chas Large

I've adjusted the code to place the "Entire Forum" option above all the selected board and post options.

In Themes/default/SearchFocus.template.php Change this:

// If specific extra boards are to be listed, go ahead and add them
$focus_boards = array();
if (!empty($modSettings['search_focus_boards']))
{
$focus_boards = unserialize($modSettings['search_focus_boards']);
foreach ($focus_boards as $brd_id => $brd_name)
{
$focus_options .= '
<option value="' . $brd_id . '">' . $brd_name . '</option>';
}
}

// Always have "entire forum" option available
$focus_options .= '
<option value="all"' . $sel . ' style="font-weight: bold;" id="search_focus_all">' . $txt['search_focus_all'] . '</option>';



to this:

// If specific extra boards are to be listed, go ahead and add them
$focus_boards = array();
if (!empty($modSettings['search_focus_boards']))
{

// Always have "entire forum" option available
$focus_options .= '
<option value="all"' . $sel . ' style="font-weight: bold;" id="search_focus_all">' . $txt['search_focus_all'] . '</option>';

$focus_boards = unserialize($modSettings['search_focus_boards']);
foreach ($focus_boards as $brd_id => $brd_name)
{
$focus_options .= '
<option value="' . $brd_id . '">' . $brd_name . '</option>';
}
}



Hope this helps anyone else who needs the same tweak.

Not yet worked out the permissions issue I raised.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

DSystem

Brazil Portuguese translation update. Was with strange characters when used UTF8


MESWEB

Quote from: Brettflan on August 13, 2010, 04:11:23 AM
Quote from: Joker™ on August 13, 2010, 03:28:36 AM
In my test site, i went in Board "A" , and searched for -> Test

Same name post is in Board "B" also

the search output url is

http://localhost/rc3/index.php?action=search2;search=test;search_focus=board;submit=Search;advanced=0;brd=

Also in result both test posts of Board "A" and "B" were shown , and i just made search for Board "A" post.

OK, I think the "brd" value is being parsed out as an array and getting lost. Try this then:

<?php
//Path to SSI.php
require(dirname(__FILE__) . '/SSI.php');

$redir 'action=search2';

foreach (
$_POST as $var => $val)
{
if( is_array($val) )
foreach ($val as $vala => $valb)
$redir .= ';' urlencode(stripslashes($var)) . '[' urlencode(stripslashes($vala)) . ']=' urlencode(stripslashes($valb));
else
$redir .= ';' urlencode(stripslashes($var)) . '=' urlencode(stripslashes($val));
}

redirectexit($redir);

?>


I paste this code to top of Search.template.php but not working. How I can see query string like search=anyword

roshaoar

Hello,

This is really nice thank you, works fine on 2.0.10. May I request, how would I add an additional custom option in the dropdown, make it default, with a URL and parameter for it to go to? I already have zoomindex on my site and the forum is just a small part of the site, so I'd like to add an option "Search entire site".

Thank you for your time,

-Johan

hong_thanawat

Hello,

I am not sure whether this mod is still active. I have a very high expectation for this mod. However, it seems the mod has not been updated for a while.

After installed 'Search Focus Dropdown', the default search box on my forum is disappeared. I have not idea how to get it back. I have uninstalled the mod  but I still can not recover the search box.

Can anyone advice me how to get the search box back with 'Search Focus Dropdown' mod? I am using SMF 2.0.11 atm.

Thank you,
Thanawat

br360

Did you do a backup before you installed the mod? When you tried to install or uninstall, were there any errors that showed?

Dwev

Is there still support for this mod? It seems that "Brettflan" hasn't been here since for almost four years.

I'm trying to get this mod to work, but it fails on the search in index.template.php in the Theme, because it can't find the following:


<input type="submit" name="submit" value="', $txt['search']


I'm using SimplePortal and a custom theme, so I'm guessing things aren't exactly standard.

I could attach my index.template.php, but if nobody is watching I'd rather not.

Advertisement: