News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Search "This board" don't work

Started by ioofen, September 15, 2015, 10:29:15 AM

Previous topic - Next topic

ioofen

After I installed a lot of mod, The Search "This board" don't work , do my best skill ,i edited code "name=sd_brd[]" to "name=sd_brd"  in " index.template", then it work again.

but i know this way is no good, someone know what is my mistake for that? Thank you ~

Illori



Oldiesmann

Do you have a search index set up? If so, what type? I just tried this on my test board and it worked as expected, finding the search result in both the subjects and the posts themselves.

Also, the line you mentioned in index.template.php should be this:

<input type="hidden" name="sd_brd[', $context['current_board'], ']" value="', $context['current_board'], '">
Michael Eshom
Christian Metal Fans

margarett

IIRC it only searches the first board, no matter in which board you're in.

Dang I forgot to properly trace that at the time :(
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Oldiesmann

Looking into this further I see what's going on:

In index.template.php we're sending sd_brd as an array:

// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="sd_brd[', $context['current_board'], ']" value="', $context['current_board'], '">';


Search.php isn't expecting this and converts the value to an array again. We then loop through the values of $_REQUEST['brd'] and make sure each is an int. Using (int) with an array in PHP will result in a value of 1 if the array isn't empty, so it will always search board 1 regardless. The fix is to change sd_brd[', $context['current_board'], '] in index.template.php to just sd_brd as described above.
Michael Eshom
Christian Metal Fans

ioofen

Quote from: Oldiesmann on September 15, 2015, 12:45:31 PM
Looking into this further I see what's going on:

In index.template.php we're sending sd_brd as an array:

// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="sd_brd[', $context['current_board'], ']" value="', $context['current_board'], '">';


Search.php isn't expecting this and converts the value to an array again. We then loop through the values of $_REQUEST['brd'] and make sure each is an int. Using (int) with an array in PHP will result in a value of 1 if the array isn't empty, so it will always search board 1 regardless. The fix is to change sd_brd[', $context['current_board'], '] in index.template.php to just sd_brd as described above.

OK~ Thank for your Confirm.

Advertisement: