News:

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

Main Menu

How add google AdSense?

Started by robertnzana, February 19, 2009, 05:23:12 PM

Previous topic - Next topic

robertnzana

Is there an easy way to add google AdSense to my forum boards?


robertnzana

Thanks.  I installed it and created a new add and copy/paste my AdSense code but it doesn't show up.  Any idea why?  Here's the forum:  http://forum.ttg911.com/ [nofollow]

jossanaijr

Did you give permissions to guest and members?
Did you edit files to your theme?  If you change to english default and it works it is because you need to edit files to your theme.

robertnzana

I have a custom theme that I've been using from the start and haven't modified it recently.  The forum should be open to everyone. 

I noticed that it shows up on the posts now but not the main boards, etc...  and it ALWAYS seems to be a public service announcement!

jossanaijr

Sorry did not understand...

Did you give permission to users?  Check all your guest and membergroups permissions tab.
Did you mark in Ad Management tab where do you want to show ads?
Did you installed the Ad Management to your SMF version?  There are 2.
Did you check if the code was updated in your theme?
Parse bellow:

Ad Management Mod
Written by: jerm (electrohome88)
Email: [email protected]
Support site: www.smfads.com

----------
This mod will display ads on various parts of your forum on the default theme in SMF Version 1.1
---------
Version 2.3 Jan 11, 2007
- New setting: Disable ads for admins
- New setting: Disable reports(one less query)
- New setting: Disable all ads
- New setting: Ability to make post ads not look like posts.
- Added the ability to display ads between categories
- Added the ability to display ads after the last post
- Added the ability to display ads under child boards
- Fixed issues about not finding functions(caused forums to crash)


Version 2.0 Jun 13, 2006
- Enabled per board ads
- Ability to add multiple ads
- HTML/PHP style ads
- Ad reports
- Disabled ads in certain sections of the admin panel
- Many more minor improvments

Version 1.5 Mar 19, 2006
- Fixed an issue with the xml
- Added the ability to display ads on top of the menu on every page
- Added help files
- Revised some of the code in previous versions.

Version 1.4.1 Feb 8, 2006
- Fixed an issue when installing on a forum that has TinyPortal installed

Version 1.4 Feb 2, 2006
- Added the ability to disable ads according to their membergroup.

Version 1.3 Feb 1, 2006
- Updated database settings so that they wont be removed on re-installation.
- Added the ability to display ads on the bottom of every page.
- Added the ability to display an ad after the first post. (Idea courtesy Joomlaspan)

Version 1.2 Jan 30, 2006
- Offically released on simplemachines.org. No offical changes from previous version.


Version 1.0 Jan 5, 2006
- Not publicly released.
- Displayed ads only under the menu bar.
File Edits
./index.php
Find: [Select]
'trackip' => array('Profile.php', 'trackIP'),
Add After: [Select]

'admod' => array('Ads.php', 'Ads'),

Find: [Select]
require_once($sourcedir . '/Security.php');
Add After: [Select]

if (file_exists($sourcedir . '/LoadAds.php'))
require_once($sourcedir . '/LoadAds.php');

Find: [Select]
loadPermissions();
Add After: [Select]

// Load all the ads up
if (function_exists("loadAds"))
loadAds();

./Sources/Subs.php
Find: [Select]
loadLanguage('Admin');
Add After: [Select]

loadLanguage('Ads');

Find: [Select]
'manage_themes' => '<a href="' . $scripturl . '?action=theme;sa=admin;sesc=' . $sc . '">' . $txt['theme_admin'] . '</a>',
Add After: [Select]

'edit_addmod' => '<a href="' . $scripturl . '?action=admod">' . $txt['ad_management'] . '</a>',

./Themes/default/index.template.php
Find: [Select]
<body>';
Add After: [Select]

//Display ads on the top of the page
if (function_exists("show_topofpageAds"))
{
$ads = show_topofpageAds();
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);
}


Find: [Select]
</td>
Add After: [Select]
';
//Welcome Ads
if (function_exists("show_welcomeAds"))
{
$ads = show_welcomeAds();
if(!empty($ads))
{
echo '<td class="windowbg2">';
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
echo '</td>';
}
unset($ads);
}
echo '

Find: [Select]
template_menu();
Add After: [Select]

//Below the menu ads
if (function_exists("show_indexAds") && function_exists("show_towerleftAds") && function_exists("show_towerrightAds"))
{
$ads = show_indexAds();
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);

//Tower left Ads
$ads = show_towerleftAds();
if(!empty($ads))
echo '<table><tr><td valign="top">', $ads['type']==0 ? $ads['content'] : eval($ads['content']) ,'</td><td width="100%" valign="top">';

unset($ads);
//Tower Right Ads
$ads = show_towerrightAds();
if(!empty($ads))
echo '<table><tr><td width="100%" valign="top">';
unset($ads);
}


Find: [Select]
// Show the "Powered by" and "Valid" logos, as well as the copyright. Remember, the copyright must be somewhere!
Add Before: [Select]

//Close table for towerright ads
if (function_exists("show_towerrightAds") && function_exists("show_towerleftAds") && function_exists("show_bottomAds"))
{
$ads = show_towerrightAds();
if(!empty($ads))
echo '</td><td valign="top">', $ads['type']==0 ? $ads['content'] : eval($ads['content']) ,'</td></tr></table>';

unset($ads);
//Close table for towerleft ads
$ads = show_towerleftAds();
if(!empty($ads))
echo '</td></tr></table>';
unset($ads);

//Show ads on the bottom of the page
$ads = show_bottomAds();
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);
}


./Themes/default/BoardIndex.template.php
Find: [Select]
// Show some statistics next to the link tree if SP1 info is off.
Add Before: [Select]

//Display ads on the board index
if (function_exists("show_boardAds"))
{
$ads = show_boardAds();
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);
}

Find: [Select]
echo '
</div>';
Add After: [Select]

//Display ads Between cats
if (function_exists("show_category"))
{
$ads = show_category($category['id']);
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);
}

./Themes/default/Display.template.php
Find: [Select]
global $context, $settings, $options, $txt, $scripturl, $modSettings;
Add After: [Select]

//Display ads on the thread page
if (function_exists("show_threadAds"))
{
$ads = show_threadAds();
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);
}

Find: [Select]
// Get all the messages...
while ($message = $context['get_message']())
{
Replace With: [Select]
//Ad Counter
$adcounter =0;
// Get all the messages...
while ($message = $context['get_message']())
{
$adcounter++;

Find: [Select]
</td></tr>';
}
Replace With: [Select]
</td></tr>';
if (function_exists("show_posts"))
{
if ($adpost = show_posts($adcounter))
{
if($modSettings['ads_lookLikePosts'])
{
echo '

<tr><td style="padding: 1px 1px 0 1px;">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr><td class="windowbg3">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="top" width="16%" rowspan="2" style="overflow: hidden;">
<b>', $context['forum_name'], '</b>
<div class="smalltext">
</div>
</td>
<td valign="top" width="85%" height="100%">
<table width="100%" border="0"><tr>
<td valign="middle"><img src="', $message['icon_url'] . '" alt="" border="0" /></td>
<td valign="middle">
<div style="font-weight: bold;" id="subject_', $message['id'], '">
<a href="', $message['href'], '">', $message['subject'], '</a>
</div>
<div class="smalltext">« <b>', !empty($message['counter']) ? $txt[146] . ' #' . $message['counter'] : '', ' ', $txt[30], ':</b> ', $message['time'], ' »</div></td>
<td align="', !$context['right_to_left'] ? 'right' : 'left', '" valign="bottom" height="20" style="font-size: smaller;">';
if ($context['can_reply'] && !empty($options['display_quick_reply']))
echo '
', $reply_button, '';

// So... quick reply is off, but they *can* reply?
elseif ($context['can_reply'])
echo '
', $reply_button, '';

// Can the user modify the contents of this post?
if ($message['can_modify'])
echo '
', $modify_button, '';

// How about... even... remove it entirely?!
if ($message['can_remove'])
echo '
', $remove_button, '';

// What about splitting it off the rest of the topic?
if ($context['can_split'])
echo '
', $split_button, '';
echo '
</td>
</tr></table>
<hr width="100%" size="1" class="hrcolor" />
<div class="post">', $adpost['type'] == 0 ? $adpost['content'] : eval($adpost['content']) , '</div>
</td>
</tr>
<tr>
<td valign="bottom" class="smalltext" width="85%">
<table width="100%" border="0" style="table-layout: fixed;"><tr>
<td colspan="2" class="smalltext" width="100%">
</tr><tr>
<td valign="bottom" class="smalltext" id="modified_', $message['id'], '">
</td>
<td align="', !$context['right_to_left'] ? 'right' : 'left', '" valign="bottom" class="smalltext">
<img src="', $settings['images_url'], '/ip.gif" alt="" border="0" />&nbsp;', $txt[511], '
</td>
</tr></table>
</tr>
</table>
</td></tr>
</table>
</td></tr>';
}
else
echo '
<tr><td style="padding: 1px 1px 0 1px;">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr>
<td class="windowbg3">', $adpost['type'] == 0 ? $adpost['content'] : eval($adpost['content']) , '</td>
</tr>
</table>
</td></tr>';
}

}

}

if(function_exists("show_lastpostAds") && function_exists("show_posts"))
{
if(($ads = show_lastpostAds()) && !show_posts($adcounter))
{
if($modSettings['ads_lookLikePosts'])
{
echo '

<tr><td style="padding: 1px 1px 0 1px;">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr><td class="windowbg3">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="top" width="16%" rowspan="2" style="overflow: hidden;">
<b>', $context['forum_name'], '</b>
<div class="smalltext">
</div>
</td>
<td valign="top" width="85%" height="100%">
<table width="100%" border="0"><tr>
<td valign="middle">&nbsp;</td>
<td valign="middle">
&nbsp;</td>
<td align="', !$context['right_to_left'] ? 'right' : 'left', '" valign="bottom" height="20" style="font-size: smaller;">';
if ($context['can_reply'] && !empty($options['display_quick_reply']))
echo '
', $reply_button, '';

// So... quick reply is off, but they *can* reply?
elseif ($context['can_reply'])
echo '
', $reply_button, '';


echo '
</td>
</tr></table>
<hr width="100%" size="1" class="hrcolor" />
<div class="post">', $ads['type'] == 0 ? $ads['content'] : eval($ads['content']) , '</div>
</td>
</tr>
<tr>
<td valign="bottom" class="smalltext" width="85%">
<table width="100%" border="0" style="table-layout: fixed;"><tr>
<td colspan="2" class="smalltext" width="100%">
</tr><tr>
<td valign="bottom" class="smalltext" id="modified_', $message['id'], '">
</td>
<td align="', !$context['right_to_left'] ? 'right' : 'left', '" valign="bottom" class="smalltext">
<img src="', $settings['images_url'], '/ip.gif" alt="" border="0" />&nbsp;', $txt[511], '
</td>
</tr></table>
</tr>
</table>
</td></tr>
</table>
</td></tr>';
}
else
echo '
<tr><td style="padding: 1px 1px 0 1px;">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr>
<td class="windowbg3">', $ads['type'] == 0 ? $ads['content'] : eval($ads['content']) , '</td>
</tr>
</table>
</td></tr>';

}

}

./Themes/default/MessageIndex.template.php
Find: [Select]
global $context, $settings, $options, $scripturl, $modSettings, $txt;
Add After: [Select]

//Display Ads on the Message index
if (function_exists("show_threadindexAds"))
{
$ads = show_threadindexAds();
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);
}

Find: [Select]
echo '
</table>
</div>';
Add After: [Select]
//Display Ads on the Message index
if (function_exists("show_underchildren"))
{
$ads = show_underchildren();
if(!empty($ads))
if($ads['type']==0)
echo $ads['content'];
else
eval($ads['content']);
unset($ads);
}


./Sources/ManagePermissions.php
Find: [Select]
'pm' => array(
Replace With: [Select]
'ad_manage' => array(
'ad_manageperm' => false,
),
'pm' => array(

robertnzana

Did you give permission to users?  Check all your guest and membergroups permissions tab.
** I went to Permissions and made sure everyone had "Enable ads" checked.

Did you mark in Ad Management tab where do you want to show ads?
** In Ad Management I kept the "boards" option blank so it would show up everywhere.  I checked all the "display boxes too."

Did you installed the Ad Management to your SMF version?  There are 2.
** I installed the Ad Management 2.3 package.  Is this enough?

Did you check if the code was updated in your theme?
** Isn't installing the package enough?  If not, where do I copy/paste this code into?

Thanks!

jossanaijr

QuoteDid you check if the code was updated in your theme?
** Isn't installing the package enough?  If not, where do I copy/paste this code into?
Mods are installed only in the Default theme and English non utf-8 language.
If you use another theme (your case) or another language you will need to edit your theme's files every time you want to install a mod.
So go to the mod download page and check parse option to your SMF version.  Then edit your theme's files according to default's theme that is shown in parse.
You need an editor (Notepad ++ for example) and do not forget to keep backup files before any changes!

robertnzana

Thanks. So I chose the default theme and now there's a big empty box...
http://forum.ttg911.com/index.php [nofollow]

jossanaijr

Quote from: robertnzana on February 20, 2009, 09:48:03 AM
Thanks. So I chose the default theme and now there's a big empty box...
http://forum.ttg911.com/index.php

It seems to me that it is working fine!

Xylar2

Quote from: robertnzana on February 20, 2009, 09:48:03 AM
Thanks. So I chose the default theme and now there's a big empty box...
http://forum.ttg911.com/index.php

Works for me too... Maybe you have an ad-block on?

JimM

robertnzana Is this issue solved or do you still require assistance?  I clicked on the last link you posted and there was an ad that seemed to work fine.  If this is solved, feel free to mark it as solved by clicking the Mark Topic Solved link at the bottom of the page under the linktree.

Jim "JimM" Moore
Former Support Specialist

topgunmike

Quote from: jossanaijr on February 20, 2009, 09:53:19 AM
Quote from: robertnzana on February 20, 2009, 09:48:03 AM
Thanks. So I chose the default theme and now there's a big empty box...
http://forum.ttg911.com/index.php [nofollow]

It seems to me that it is working fine!

Sometimes, it can take some time for the ads to appear, until the appear From Google, all you will see is the Empty box where the ads will be.
It's usualy not long, but I've seen it take a hour or two to finaly come on from Google.

Advertisement: