News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Get Paid: Add Google Results Within Your Forum (rc2)

Started by Mick., February 23, 2010, 10:07:54 PM

Previous topic - Next topic

Mick.

Get Paid: Add Google Results Within Your Forum  (rc2)

Demo:  Google Custom Search Box in my site

Assuming you have access to the server...

First off...... create a file named:   results.php  (where SMF is installed).


Go to Google.com and create an account with webmasters, http://www.google.com/webmasters/

Once you've done that, go to settings and click on "adsense", sign-in, click on "adsense setup", then select: "adsense for search".


On that page follow thru to create the "search code".  It will ask you where do you want the results to appear.  Select "within" and
type the URL of your site with results.php at the end. i.e. yoursite.com/results.php

Once done, it will provide 2 codes.   One for the index.template.php and the other for the results.php you created.


The codes:

In your newly created page (results.php) insert:

<?php require("/home/*******/public_html/SSI.php");
$context['page_title_html_safe'] = 'Results';
template_header();
echo
'
<br />


<center><div id="cse-search-results"></div>
<script type="text/javascript">
 var googleSearchIframeName = "cse-search-results";
 var googleSearchFormName = "cse-search-box";
 var googleSearchFrameWidth = 800;
 var googleSearchDomain = "www.google.com";
 var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>

</center></td>
       </tr>
   </tbody>
</table>'
;

template_footer(); ?>


Remember to replace this part with the full path of your forum in the code above.  (line 1)
<?php require("/home/*******/public_html/SSI.php"); and the google code with yours.


.....and the search bar button:

In your default theme index.template.php find:


echo '
</div>
<div class="news normaltext">
<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />&nbsp;
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';


and replace with the first code google provided you.

Should look like this:

echo '
</div>
<div class="news normaltext">
<form action="http://www.bluedevilcustoms.com/results.php" id="cse-search-box">
  <div>
    <input type="hidden" name="cx" value="partner-pub-0022808160619558:6qzqmw-6ffz" />
    <input type="hidden" name="cof" value="FORID:10" />
    <input type="hidden" name="ie" value="ISO-8859-1" />
    <input type="text" name="q" size="31" />
  </div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>';


Remember these are my codes.  Just replace the codes with what google provided you.

Also,.... i woundnt remove the SMF search button from the Nav bar if you have less than a 200 posts.  Meaning that chances are, not all your posts are indexed yet.   Google search results only works if threads are indexed.  If not, the page results will show zero results.



Tuddley3

Are you saying this will help me make money to help pay for my website/forum? Kind of like a sponsor?

Mick.

Quote from: Tuddley3 on March 15, 2010, 05:51:59 PM
Are you saying this will help me make money to help pay for my website/forum? Kind of like a sponsor?

Sure,....its adsense.   If folks click on the results, pennies will accumulate to your google adsense account.

Dont expect to get rich tho'.

aw06

Does't seem to be working for rc3, cant install it
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

Ok, got it working, is it possible to have logged in users stay logged after entering a search ?
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Mick.

Quote from: aw06 on March 28, 2010, 07:35:53 AM
Ok, got it working, is it possible to have logged in users stay logged after entering a search ?
what do you mean?

aw06

Quote from: bluedevil on March 28, 2010, 10:29:26 AM
Quote from: aw06 on March 28, 2010, 07:35:53 AM
Ok, got it working, is it possible to have logged in users stay logged after entering a search ?
what do you mean?

If i am logged into my forum ... when i do a search the results page shows me logged out.... google has not indexed my site yet so i can't check if when i click a link it will log me back in.
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Mick.

Quote from: aw06 on March 28, 2010, 10:32:20 AM

If i am logged into my forum ... when i do a search the results page shows me logged out.... google has not indexed my site yet so i can't check if when i click a link it will log me back in.

1.1.11 or rc3?

Mick.

Did you add your own path in line 1?

<?php require("/home/*******/public_html/SSI.php");


Im not sure why it logs you out.   In all my sites i stay logged in.

aw06

by own path you mean

<?php require("/home/serverusername/public_html/forum/SSI.php");

if so yes...
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

Can you run some test seaches on my site ... http://www.photojamaica.net/forum/results.php it seems to be mostly finding youtube results...  :-\
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Mick.

Dang!.... your site looks good.   I just searched "jamaica" and it returned a handful of pages.

Im curious..... when you setup your account,... did you selected results from the web or your website?

aw06

Quote from: bluedevil on March 28, 2010, 05:44:56 PM
Dang!.... your site looks good.

Thanks :) i just need a flash image rotator similar to yours now  :P :P Always wanted to run 2.0 and a Dziner Theme as i think they are the best, i may install more Dziner themes on my other forums 8)

Selected both seach methods, mine taking priority ... i only set it to this because the site is no more then 2 days running now, so nothing indexed as yet

Also in google chrome their is a big chunk of space below the search results and footer, it's the same in your site as well ...
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Mick.

Quote from: aw06 on March 28, 2010, 06:23:54 PM
Quote from: bluedevil on March 28, 2010, 05:44:56 PM
Dang!.... your site looks good.

Thanks :) i just need a flash image rotator similar to yours now  :P :P Always wanted to run 2.0 and a Dziner Theme as i think they are the best, i may install more Dziner themes on my other forums 8)

Selected both seach methods, mine taking priority ... i only set it to this because the site is no more then 2 days running now, so nothing indexed as yet

Also in google chrome their is a big chunk of space below the search results and footer, it's the same in your site as well ...

That blows....  i dont use Chrome.   Only IE8 & FF.

The minute Chrome becomes popular like FF, then i'll worry about it.

Mick.

I dont know if its a mod but contact ccbtimewiz @dzinerstudio.  He gave me the header rotator zip.

aw06

Quote from: bluedevil on March 28, 2010, 08:14:37 PM
I dont know if its a mod but contact ccbtimewiz @dzinerstudio.  He gave me the header rotator zip.

header rotator ? what you see you have is a set of images rotating in the top block... but i thinnk you mentioned it's not free
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Advertisement: