Add Google AdSense inside Kunena Forum for Joomla PDF Print E-mail

google_adsense_thumb You can easily add Google Ads embedded in the forum listing with Kunena Forum 1.0.8. Follow the steps in this simple tutorial.

  1. Go to the Administrator and select the menu Components > Kunena Forum

  2. Click on Kunena Configuration

  3. Scroll down to the Frontent parameters and locate the Template setting

    kunena_config_template

  4. Locate the view.php file in the Kunena installation:

    {$JOOMLA}/components/com_kunena/template/{TEMPLATE_NAME}/view.php

    where

    {$JOOMLA} is the Joomla installation folder
    {TEMPLATE_NAME} is the name of the template that you are using

  5. Make a backup copy of the view.php file.

  6. Go to Google AdSense and get desired ad code.

  7. Open view.php in your favorite text editor. Locate the following lines, around line 1195:

      1 
      2 
      3 

      4 

      5 
      6 
      7 

      8 
      9 
     10 
     11 
     12 
     13 
     14 
     15 
     16 
    <?php
                                    
    //(JJ)
                                    
    if (file_exists(KUNENA_ABSTMPLTPATH 
                                      '/message.php'
    )) {
                                        include (
    KUNENA_ABSTMPLTPATH 
                                          '/message.php'
    );
                                    }
                                    else {
                                        include (
    KUNENA_ABSPATH 
                                          '/template/default/message.php'
    );
                                    }

                                    unset(
                                    
    $msg_id,
                                    
    $msg_username,
                                    
    $msg_avatar,
                                    
    $msg_usertype,
                                    
    $msg_userrank,
    ?>                                



  8. Add your Google AdSense code:

      1 
      2 
      3 

      4 

      5 
      6 
      7 

      8 
      9 
     10 
     11 
     12 

     13 
     14 
     15 
     16 
     17 
     18 
     19 
     20 
     21 
     22 

     23 
     24 
     25 
     26 
     27 
     28 
     29 
     30 
     31 
     32 
     33 
     34 
    <?php
                                    
    //(JJ)
                                    
    if (file_exists(KUNENA_ABSTMPLTPATH 
                                      '/message.php'
    )) {
                                        include (
    KUNENA_ABSTMPLTPATH 
                                          '/message.php'
    );
                                    }
                                    else {
                                        include (
    KUNENA_ABSPATH 
                                          '/template/default/message.php'
    );
                                    }

                    
    // Google AdSense ---> start
                    
    if ( $mmm == ) {
                        echo 
    '<div style="margin-top: 10px;margin-bottom: 10px;">' .
                          "\n"
    ;
                        echo 
    '<script type="text/javascript"><!--' "\n";
                        echo 
    'google_ad_client = "pub-1348872499180295";' "\n"
                        echo 
    "/* 728x90, created 3/17/09 */\n"
                        echo 
    'google_ad_slot = "7075580028";' "\n"
                        echo 
    "google_ad_width = 728;\n";
                        echo 
    "google_ad_height = 90;\n";
                        echo 
    "//-->\n";
                        echo 
    "</script>\n";
                        echo 
    '<script type="text/javascript"' "\n"
                        echo 
    'src="http://pagead2.googlesyndication.com/pagead/show_
                          ads.js">' 
    "\n"
                        echo 
    "</script>\n";
                        echo 
    "</div>\n";
                    }
                    
    // Google AdSense ---> end

                                    
    unset(
                                    
    $msg_id,
                                    
    $msg_username,
                                    
    $msg_avatar,
                                    
    $msg_usertype,
                                    
    $msg_userrank,
    ?>                                



  9. Done!


The forum at Joomla-R-Us is using this little hack. Here's a sample thread where you can see this in action.

Comments (6)add comment

blinx said:

0
...
hi, thanks for this help. Will be the Adsense Ad shown only once in the thread,or do I have to place the code more times? (in the case the page with comments is too long)
 
April 30, 2009
Votes: +1

wvrapscene said:

0
...
You need to add a ; at the end of line 23

It should be: echo "
";
 
September 04, 2009
Votes: +1

admin@Joomla-R-Us.com said:

admin
...
@wvrapscene: Thanks! Fixed!
 
November 30, 2009
Votes: -1

srk said:

0
...
Hi,
I followed the steps and also waited for 1 hr to see if google ads appear in between threads replies but didnt see anything. Can you please let me know if i am missing something here.

Here is the link of my website were is was trying to get this done:
http://cinemagrounds.com/index.php/forum.html

can you please help.
 
May 05, 2010
Votes: +0

finixx said:

May 06, 2010
Votes: +0

myself said:

0
...
Kunena - component created to solve problemd which never existed in other forum components.
 
August 09, 2010
Votes: +0

Write comment

security image
Write the displayed characters


busy
 
 
  Design by augs-burg.de & go-vista.de  
 
     
 
   
 

The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries. http://Joomla-R-Us.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.