Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3627)
Search Topic And Board Button v1.0
Add "Search This Topic" And "Search This Board" Button in Display.template.php and MessageIndex.template.php
Compatibility
SMF 2.0
Mod by: Mr. Pedram (http://www.simplemachines.org/community/index.php?action=profile;u=323252)
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi.creativecommons.org%2Fl%2Fby-nc-nd%2F3.0%2F88x31.png&hash=8719f18c90cbd576bc578f378c0dbf23030467d6)
This mod is licensed under a CC BY-NC-ND 3.0 (http://creativecommons.org/licenses/by-nc-nd/3.0/)
Wow, this is a great idea...!! thanks for share
Great mod, trying now.
excellent idea. why has nobody thought of this before.
Mostly because SMF does most of it out of the box?
If you're in a topic already and use the quick search, it will only search that topic (and has done since 1.0)
If you're in a board already and use the quick search, it will only search that board.
All this really does is provide a UI for functionality that's been there for 10 years.
I am also curious as to the necessity of the edit to the search template to add what looks like another 'search' button when there's already one there...
not sure why theres a search edit.
and its not working for me, just takes me to a regular search, but that could be the fault of my slightly vandalised installation.
Thanks to everyone, this mod most usefull for custom them, not default smf them, due some themes haven't "Quick Search Bar"
Quote from: dimspace on February 08, 2013, 08:10:04 PM
not sure why theres a search edit.
and its not working for me, just takes me to a regular search, but that could be the fault of my slightly vandalised installation.
Same for me. Does not custom search boards. Topic search works though.
ok you right, look like something went wrong , i'll check it.
Quote from: Arantor on February 08, 2013, 08:02:38 PM
...If you're in a topic already and use the quick search, it will only search that topic (and has done since 1.0)
If you're in a board already and use the quick search, it will only search that board.
All this really does is provide a UI for functionality that's been there for 10 years.
I am also curious as to the necessity of the edit to the search template to add what looks like another 'search' button when there's already one there...
Well in our case the
Quick Search opens a custom Google Search page not restricted to a given thread so that Search within a thread button is really useful so
thank you Mr. Pedram for sharing! 8)
I did not test the mod yet, will report later.
To differentiate from Quick & Advanced Search I would prefer that it would say "Search Thread" or "Search This Thread". At the present:
Quote from: LexusFTW on February 13, 2013, 01:06:51 PM
Does not custom search boards. Topic search works though.
I have the same issue with this mod on my forums (one of which does not have a 'Quick Search' option at the top because of the theme I am using) so today I decided to have a go at fixing it. By making the following changes the 'Search' button displayed at the top of the Message Index will open a Search form that only searches the current board.
In ./Sources/Search.phpFind:
if (!empty($_REQUEST['topic']))
Add Before:
// Search Topic and Board Button mod.
// If $_REQUEST['board'] is set, that means we're searching just one board.
if (!empty($_REQUEST['board']))
{
$context['search_params']['board'] = (int) $_REQUEST['board'];
$context['search_params']['show_complete'] = true;
}
if (!empty($context['search_params']['board']))
{
$context['search_params']['board'] = (int) $context['search_params']['board'];
$context['search_board'] = array(
'id' => $context['search_params']['board'],
'href' => $scripturl . '?board=' . $context['search_params']['board'] . '.0',
);
$request = $smcFunc['db_query']('', '
SELECT name
FROM {db_prefix}boards
WHERE id_board = {int:search_board}
LIMIT 1',
array(
'search_board' => $context['search_params']['board'],
)
);
if ($smcFunc['db_num_rows']($request) == 0)
fatal_lang_error('topic_gone', false);
list ($context['search_board']['name']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$context['search_board']['link'] = '<a href="' . $context['search_board']['href'] . '">' . $context['search_board']['name'] . '</a>';
}
Find:
// Ensure that brd is an array.
Add Before:
// Search Topic and Board Button mod.
// If $_REQUEST['board'] is set, that means we're searching just one board.
elseif (!empty($_REQUEST['board']))
$_REQUEST['brd'] = $_REQUEST['board'];
In ./Themes/default/Search.template.phpFind:
// If $context['search_params']['topic'] is set, that means we're searching just one topic.
Add Before:
// Search Topic and Board Button mod.
// Added code to show which board is being searched when using search button at top of board.
// If $context['search_params']['board'] is set, that means we're searching just one board.
if (!empty($context['search_params']['board']))
echo '
<p>', $txt['search_specific_board'], ' <em>"', $context['search_board']['link'], '"</em>.</p>
<input type="hidden" name="board" value="', $context['search_board']['id'], '" />';
Find:
if (empty($context['search_params']['topic']))
Replace With:
// Search Topic and Board Button mod.
// Added code to exclude board selection is searching from button at top of board.
//if (empty($context['search_params']['topic']))
if (empty($context['search_params']['topic']) && empty($context['search_params']['board']))
In ./Themes/default/languages/Search.english.phpFind:
$txt['search_specific_topic'] = 'Searching only posts in the topic';
Add After:
// Search Topic and Board Button mod.
$txt['search_specific_board'] = 'Searching only posts in the board';