Adsense Search

Discussions about the phpBB3 Forum. How to get the best from this powerful script.
Note that there is no official support for phpBB3 here, a place to share more than to ask for.

Moderator: Moderators

Adsense Search

Postby Asira » Sat Aug 15, 2009 3:58 pm

Hi there,

i would like to setup adsense search like on this page. Above advanced search i will be able to put the search box BUT how will i be able to show results like you did here... on same page and under the search box? What should i select on Adsense Settings? Open results on same page gives me different results :(

Image
User avatar
Asira
 
Posts: 39
Joined: Sat Aug 15, 2009 2:04 pm

Advertisement

Re: Adsense Search

Postby Typo » Sat Aug 15, 2009 11:20 pm

I went ahead and made a search page to test this to make sure I wasn't giving bad advice as it has been some time since I made a search page.

Ok, while going through the adsense search code creator thing, make sure to select "Open results within my own site" and then enter the url of the page that the results will be displayed on. This can be the same page as the one the search bar is on or a different page. For me it is http://www.aplacetochat.com/look.php . Notice how I use the .php and not the .html even tho the search code actually goes into the .html .

So, the easiest way I believe will be for me to give you the url to the page I just made, and give you the code I used to make it.

Here goes.

The new search page URL, as stated above, is http://www.aplacetochat.com/look.php .

Keep in mind, I have put no code into place to not show the results box unless there are results so this means when you first load the searcg page, the user will see a box that says search results and it in fact will have no results at all.. This is just an example so I saw no problem with this. You would normally have all the search boxes point to look.php so that it will only be loaded when a search has been made. Then, there will never be an issue with the empty results section. There are many different ways you can go about this all but I just wanted to give you something you could look at.

The code:
/look.php

Code: Select all
<?php

    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    page_header('A Place To Chat Custom Search');

    $template->set_filenames(array(
        'body' => 'look.html',
    ));

    page_footer();

?>

/styles/prosilver/template/look.html

Code: Select all
<!-- INCLUDE overall_header.html -->
   <div class="panel">
      <div class="inner"><span class="corners-top"><span></span></span>
      <table width="100%" cellspacing="0" cellpadding="0" border="0">
         <tr>
            <th><h2>A Place To Chat Custom Search</h2></th>
         </tr>
         <br />
         <tr>
            <td align="center">
               <form action="http://www.aplacetochat.com/look.php" id="cse-search-box">
                  <div>
                     <input type="hidden" name="cx" value="partner-pub-6863818085689529:knlnyyg1qs4" />
                     <input type="hidden" name="cof" value="FORID:10" />
                     <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&amp;lang=en"></script>
            </td>
         </tr>
      </table>
      </div>
   <span class="corners-bottom"><span></span></span></div>
   </div>
   <br />
   <div class="panel">
      <div class="inner"><span class="corners-top"><span></span></span>
      <div class="content">
         <table width="100%" cellspacing="0" cellpadding="0" border="0">
            <tr>
               <th><h2>A Place To Chat Custom Search Results</h2></th>
            </tr>
            <br />
            <tr>
               <td align="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>
               </td>
            </tr>
         </table>
      </div>
   <span class="corners-bottom"><span></span></span></div>
   </div>
<!-- INCLUDE overall_footer.html -->


This should get you going.

:mrgreen: Please don't pick on me for my coding, I did just toss this together on the fly. :mrgreen:

Typo
User avatar
Typo
phpBB SEO Team
phpBB SEO Team
 
Posts: 346
Joined: Sun Jan 18, 2009 11:33 am


Return to phpBB Forum

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 100 guests