News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Placing code for custom google search

Started by learjet45, September 06, 2008, 01:46:33 PM

Previous topic - Next topic

learjet45

Hey there. Just a quick question.
In what part of which file should I place the code for my custom google search? I want it to show at the bottom of topics after reply, notify, etc links and above the topic moderation links. Here is a little idea to show where I want it:

By the way, im using the black45 theme.

[SiNaN]

../Themes/default/Display.template.php (not in black45 theme, in default)

Find:

if ($context['show_spellchecking'])

Add before:

echo 'YOUR_CODES_GO_OVER_HERE';

Do not foget to replace ' as \' in your codes.
Former SMF Core Developer | My Mods | SimplePortal

learjet45

Alright, thanks. If I have issues I will post.

learjet45

Alright. I was trying to do this, and I'm kind of confused by what you mean by the Do not foget to replace ' as \' in your codes. What exactly do I change for that?

[SiNaN]

Inside the echo you should escape you single quotes ('). Example:

// This is wrong
echo 'This is a test. I'm really good.';


// This is correct
echo 'This is a test. I\'m really good.';

Former SMF Core Developer | My Mods | SimplePortal

learjet45


learjet45

Alright. I have tried to get it working and I cant. I've tried a bunch of different things, and I just cant get it to show up. It's the same code as the search box i placed on my portal (simpleportal, wonderful portal). Here is my code:

<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">  <div>    <input type="hidden" name="cx" value="partner-pub-5508946442592156:8dbd62crtp3" />    <input type="hidden" name="ie" value="ISO-8859-1" />    <input type="text" name="q" size="31" />    <input type="submit" name="sa" value="Search" />  </div></form><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></center>

Here is what it looks like right now:

if ($context['show_spellchecking'])
echo '
<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">  <div>    <input type="hidden" name="cx" value="partner-pub-5508946442592156:8dbd62crtp3" />    <input type="hidden" name="ie" value="ISO-8859-1" />    <input type="text" name="q" size="31" />    <input type="submit" name="sa" value="Search" />  </div></form><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></center>

<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/spellcheck.js"></script>';

I have tried it with the '; after the search box code, I have made sure there are no extra ' in the code and there arent. I dont get whats wrong.

[SiNaN]

My "add before" is not like the one in the mod packages unfortunately. :)

It should look like this:

echo 'YOUR CODES';

if ($context['show_spellchecking'])
Former SMF Core Developer | My Mods | SimplePortal

learjet45


learjet45

Strange, I try to search for something, and it says:
Quote
An Error Has Occurred!
Session verification failed. Please try logging out and back in again, and then try again.

[SiNaN]

Hmmm, I forgot about the form we have there. Try adding it just before this line:

echo '
<div class="tborder"><div class="titlebg2" style="padding: 4px;" align="', !$context['right_to_left'] ? 'right' : 'left', '">
Former SMF Core Developer | My Mods | SimplePortal

learjet45

Hmmm
I removed the old code, added the new one, and no im getting errors. I put up the backup i made before hand. Maybe ill just worry about it another time.

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

learjet45

I dont remember exactly, but the topics wouldnt load at all. It was giving a reminder that it might be a single ' that wasnt escaped, but there arent any single ' in the code.

[SiNaN]

Maybe you forgot to add a single quote somewhere in the codes. If you are still interested in this, you can attach your file here so that we can check it.
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: