Advertisement:

Author Topic: Adding AutoSuggest to Search for 'By user' field  (Read 1929 times)

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 436
  • Gender: Female
Adding AutoSuggest to Search for 'By user' field
« on: July 24, 2018, 03:29:21 AM »
To add  AutoSuggest to the 'By user' field for searches modify ./Themes/default/Search.template.php as follows:

Find:
Code: [Select]
<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:
Code: [Select]
<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>

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,702
  • Mod King
    • XPtsp.com Community
Re: Adding AutoSuggest to Search for 'By user' field
« Reply #1 on: August 16, 2018, 10:34:19 PM »
Nice idea, GL700Wing!
News: Missing GitHub repository...

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Online vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 20,385
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Adding AutoSuggest to Search for 'By user' field
« Reply #2 on: August 16, 2018, 10:41:38 PM »
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

Offline GigaWatt

  • The Smiley Guy
  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,148
  • Gender: Male
    • Macedonian electronics forum
Re: Adding AutoSuggest to Search for 'By user' field
« Reply #3 on: August 23, 2018, 09:15:14 PM »
Just added it to my forum, works great 8).

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

Offline GigaWatt

  • The Smiley Guy
  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,148
  • Gender: Male
    • Macedonian electronics forum
Re: Adding AutoSuggest to Search for 'By user' field
« Reply #4 on: August 30, 2018, 02:45:31 PM »
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?"..."

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 436
  • Gender: Female
Re: Adding AutoSuggest to Search for 'By user' field
« Reply #5 on: August 30, 2018, 08:21:39 PM »
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".
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:
Code: [Select]
<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:
Code: [Select]
<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>

Offline GigaWatt

  • The Smiley Guy
  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,148
  • Gender: Male
    • Macedonian electronics forum
Re: Adding AutoSuggest to Search for 'By user' field
« Reply #6 on: August 30, 2018, 08:42:45 PM »
Yep, that solved it ;).
"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?"..."

Offline EthanR

  • Semi-Newbie
  • *
  • Posts: 25
Re: Adding AutoSuggest to Search for 'By user' field
« Reply #7 on: September 05, 2018, 05:49:40 PM »
Thanks :) Working nicely.