News:

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

Main Menu

Search Focus Dropdown

Started by Brettflan, February 14, 2009, 02:34:48 PM

Previous topic - Next topic

Spoogs

Switch to the SMF default theme and see if its working properly there

HunterP

Quote from: Spoogs on November 30, 2010, 01:04:12 AMSwitch to the SMF default theme and see if its working properly there

Ok, that seems to work better... What could be the problem with the oxygen11final theme?

Spoogs

As Brettflan said, something probably wasnt edited properly.

Brettflan

Quote from: HunterP on November 30, 2010, 12:24:46 AM
Yes, I'm using a custom theme (oxygen11final) :
<snip>
I notice that the Google option was removed in that code snippet, which is why it's not showing up in your theme.
As for why topic searches aren't working correctly, I don't know for sure without really taking the time to investigate that particular theme myself and quite frankly I don't feel like spending the necessary time and effort to do that. My best guess for likely cause would be the that theme not setting the 'topic' value in the search form like usual. Look for code like this (taken from the 1.x default Core theme's index.template.php):
// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';

I suspect that's missing in the theme you're using.

HunterP

Quote from: Brettflan on November 30, 2010, 01:56:18 AMI notice that the Google option was removed in that code snippet, which is why it's not showing up in your theme.

It also doesn't show up when I use the original modification.

Quote from: Brettflan on November 30, 2010, 01:56:18 AMMy best guess for likely cause would be the that theme not setting the 'topic' value in the search form like usual.

If current_topic was missing in my theme, the dropdown box shouldn't get a "topic" entry, or does it?

// Viewing a topic?
[b] if (!empty($context['current_topic']))
[/b] {
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
$focus_options = '
[b] <option value="topic" selected="selected">' . $txt['search_focus_topic'] . '</option>
[/b] <option value="board">' . $txt['search_focus_board'] . '</option>
<option value="all">' . $txt['search_focus_all'] . '</option>';
}


When viewing a topic, I get to see all three options. So far, so good :)

Ah I found it :

               <input type="submit" name="submit" value="', $txt[182], '" style="width: 8ex;" />&nbsp;
                                                <a href="', $scripturl, '?action=search;advanced">', $txt['smf298'], '</a>
                                                <input type="hidden" name="advanced" value="0" />';

I found this in my theme :

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

  echo '
</form></div>';

<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
<input type="hidden" name="advanced" value="0" />';


Replaced it by :

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';

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

echo '
</form>


Seems to be working correctly now :)

henrik1782

#185
Hi thanks for this mod...

Here is the danish translation

SearchFocus.danish.php

<?php
// SearchFocus
// encoding: ISO-8859-1

$txt['search_focus_topic'] = 'Dette emne';
$txt['search_focus_board'] = 'Denne kategori';
$txt['search_focus_all'] = 'Hele forum';

$txt['search_focus_google'] = 'Google søgning';

$txt['search_focus_enable_google'] = 'Aktiverer Google søgning som et valg i dropdown menu';

?>




SearchFocus.danish-utf8.php

<?php
// SearchFocus
// encoding: ISO-8859-1

$txt['search_focus_topic'] = 'Dette emne';
$txt['search_focus_board'] = 'Denne kategori';
$txt['search_focus_all'] = 'Hele forum';

$txt['search_focus_google'] = 'Google søgning';

$txt['search_focus_enable_google'] = 'Aktiverer Google søgning som et valg i dropdown menu';

?>



Best regards
Henrik Poulsen
My favorite mods: Forum Firewall, httBL, MessagePreviewOnHover, BoardHover Mod, VB Style Board Index, Separate Replies and Views Column, Realtime clock by Joker, ENotify, Topic Solved.

hcfwesker

Was wondering why this wasn't a default option, since it's on the support site.   Thanx for sharing this function with other forums.

A question, though ...  anyway to add custom search tabs, like if i wanted to let members search just the Shop for a certain item?


Brettflan

It's certainly possible, but only if you really know what you're doing.

Petter B

A very nice mod, thanks. But now I have a problem.
I just updated to RC4 and the latest version of this mod.
Inside boards and topics, I now get a double menu...

Brettflan

Quote from: Petter B on December 22, 2010, 03:11:05 AM
A very nice mod, thanks. But now I have a problem.
I just updated to RC4 and the latest version of this mod.
Inside boards and topics, I now get a double menu...

My best guess is that it didn't get uninstalled properly from that theme before you reinstalled the mod package. With these pre-final releases of SMF 2.0 you should make it a habit to uninstall all packages and upload clean copies of any custom themes (preferably updated copies of the themes released for the new SMF version) before running the upgrade.
You might need to either manually edit that out, or uninstall this mod package and revert to a clean original copy of the theme's index.template.php file before reinstalling it (and the same with any other mods which have modified that file).

Petter B

Thanks. Fortunally, it was only a test-version of the forum this time. So I probably get it right in the real forum.

alsaka

i installed successfully this mod but i working with other themes
themes name ( smf pro alpha )

i know i must do this in me theme
/Themes/default/index.template.php
find this
<input type="submit" name="submit" value="', $txt['search'] <<<Does not exist

add befor
';

loadLanguage('SearchFocus');

// Viewing a topic?
if (!empty($context['current_topic']))
{
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';
$focus_options = '
<option value="topic" selected="selected">' . $txt['search_focus_topic'] . '</option>
<option value="board">' . $txt['search_focus_board'] . '</option>
<option value="all">' . $txt['search_focus_all'] . '</option>';
}
// Viewing a board?
elseif (!empty($context['current_board']))
$focus_options = '
<option value="board" selected="selected">' . $txt['search_focus_board'] . '</option>
<option value="all">' . $txt['search_focus_all'] . '</option>';
// Viewing something else, such as index
else
$focus_options = '
<option value="all" selected="selected">' . $txt['search_focus_all'] . '</option>';

// Google option enabled?
if (!empty($modSettings['search_focus_enable_google']))
$focus_options .= '
<option value="google">' . $txt['search_focus_google'] . '</option>';

// Show the search focus dropdown
echo '
<select name="search_focus" id="search_focus">' . $focus_options . '
</select>';

echo '


i don't find this code in my theme

Brettflan

This theme?
I don't see a search box in the screenshots of that theme. That's what this mod alters, so if it's removed in that theme then you're out of luck.

alsaka

yes this is theme
in theme There is no search box

can i add this by this mod or must theme have it frist

Brettflan

As I said, this mod alters the search box. If it's not there in the first place, it can't be altered. It must already exist in the theme.

alsaka

thx Brettflan for replay

please can you down theme and try to add him in this theme

if you can

Brettflan

Sorry, you'd need to take that up with the theme author. He took the trouble of completely removing the quick search form, presumably he had a reason.

hcfwesker

Getting several errors in the Error Log, and I can't figure them out.  Hoping you may have an idea.

When viewing profile pages.  (also shows up on other pages, but is the same Error)
http://www.brawldomain.com/AASMF2/index.php?action=profile;u=14

2: Invalid argument supplied for foreach()

File: /home/brawldom/public_html/AASMF2/Themes/default/languages/SearchFocus.english.php (summary sub template - eval?)
Line: 101



When using the search
http://www.brawldomain.com/AASMF2/index.php?action=search2

8: Undefined index: title

File: /home/brawldom/public_html/AASMF2/Themes/default/languages/SearchFocus.english.php (body_above sub template - eval?)
Line: 480


http://www.brawldomain.com/AASMF2/index.php?action=search2

8: Undefined index: href

File: /home/brawldom/public_html/AASMF2/Themes/default/languages/SearchFocus.english.php (body_above sub template - eval?)
Line: 479



This is, I check the SearchFocus.english.php , and not much on there ... so I'm completely lost.


Brettflan

Yeah, SearchFocus.english.php should consist of just this:

<?php
// SearchFocus
// encoding: ISO-8859-1

$txt['search_focus_topic'] = 'This topic';
$txt['search_focus_board'] = 'This board';
$txt['search_focus_all'] = 'Entire forum';

$txt['search_focus_google'] = 'Google';

$txt['search_focus_enable_google'] = 'Enable Google site-search as a search dropdown option';

?>


There are nowhere near 101 lines in the file as provided, let alone 479 or 480.

The mod package as a whole additionally never references 'title' or 'href' array indexes and does not use a foreach loop. Assuming your SearchFocus.english.php is unmodified, I'd say the error is unrelated to this package.

Since the error reporting seems completely off base, you might want to go into your Admin panel and go to Configuration->Features and Options->General. Make sure the option "Disable evaluation of templates" is unchecked. Only check that option once you've fully tested your themes and know that they work flawlessly.

hcfwesker

QuoteSince the error reporting seems completely off base, you might want to go into your Admin panel and go to Configuration->Features and Options->General. Make sure the option "Disable evaluation of templates" is unchecked. Only check that option once you've fully tested your themes and know that they work flawlessly.

I don't have that option at all in my AdminCP.  I'm on SMF2 RC4

Advertisement: