News:

Wondering if this will always be free?  See why free is better.

Main Menu

Adding AutoSuggest to Search for 'By user' field

Started by GL700Wing, July 24, 2018, 03:29:21 AM

Previous topic - Next topic

GL700Wing

To add  AutoSuggest to the 'By user' field for searches modify ./Themes/default/Search.template.php as follows:

Find:
<dd><input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>

Replace With:
<dd><input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" />
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
<script type="text/javascript"><!-- // --><![CDATA[
var oAdduserspec = new smc_AutoSuggest({
sSelf: \'oAdduserspec\',
sSessionId: \'', $context['session_id'], '\',
sSessionVar: \'', $context['session_var'], '\',
sSuggestId: \'userspec\',
sControlId: \'userspec\',
sSearchType: \'member\',
sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
bItemList: false
});
// ]]></script>
</dd>
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas


vbgamer45

Nice, I think I could use this in some mods that I do.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

GigaWatt

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

GigaWatt

There is just one small bug. It doesn't check whether you're a guest or not and suggests a nick in either case (logged in or not). I have disabled the Memberlist for guests on my forum, so this is kind of small "leak".

It's not that big of a deal, I'd still keep running it ;). It's not that guests can't check active members on the forum, read their nick and search by it in the Advanced Search box ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

GL700Wing

Quote from: GigaWatt on August 30, 2018, 02:45:31 PMThere is just one small bug. It doesn't check whether you're a guest or not and suggests a nick in either case (logged in or not). I have disabled the Memberlist for guests on my forum, so this is kind of small "leak".
I also don't allow guests to view the memberlist (or to view a member's profile summary) so I don't really consider it an issue.  However, it is easy to change the behaviour  ...




To add  AutoSuggest to the 'By user' field for searches only where viewing of the memberlist or viewing of member profile summaries is allowed modify ./Themes/default/Search.template.php as follows:

Find:
<dd><input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>

Replace With:
<dd><input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" />';

if (allowedTo('view_mlist') || allowedTo('profile_view_any'))
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
<script type="text/javascript"><!-- // --><![CDATA[
var oAdduserspec = new smc_AutoSuggest({
sSelf: \'oAdduserspec\',
sSessionId: \'', $context['session_id'], '\',
sSessionVar: \'', $context['session_var'], '\',
sSuggestId: \'userspec\',
sControlId: \'userspec\',
sSearchType: \'member\',
sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
bItemList: false
});
// ]]></script>';

echo '
</dd>

Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GigaWatt

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."


Advertisement: