News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Search Topic And Board Button

Started by Mr. Pedram, February 06, 2013, 03:38:11 PM

Previous topic - Next topic

Mr. Pedram

Link to Mod

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


This mod is licensed under a CC BY-NC-ND 3.0
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

4Kstore

Wow, this is a great idea...!! thanks for share

¡¡NEW MOD: Sparkles User Names!!!

Sudhakar Arjunan

Working on New Mods & Themes for SMF... Will update soon... My Blog page
My Smf forum : Discuss ITAcumens :: My SMF Forum

dimspace

excellent idea. why has nobody thought of this before.

Arantor

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...

dimspace

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.

Mr. Pedram

Thanks to everyone, this mod most usefull for custom them, not default smf them, due some themes haven't "Quick Search Bar"
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

LexusFTW

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.

Mr. Pedram

ok you right, look like something went wrong , i'll check it.
My Modifications:
» Loading For SMF
» Buddies Block
» Redirect Links
» Birthdate On Registration
» PM Warning
» Instagram
» Add Table,Td,Tr Button
» Search Topic & Board Button
Browse All...

PierreP_whited00r_com

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:

GL700Wing

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.php

Find:
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.php

Find:
// 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>&quot;', $context['search_board']['link'], '&quot;</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.php

Find:
$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';
Life doesn't have to be perfect to be wonderful ...

Advertisement: