Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Adsense code
Avatar
Christian Pagan
Florida
Member
Free Members
sp_UserOfflineSmall Offline
Jun 3, 2012 - 10:36 pm

where am I adding this in the functions file and then I need to show that ad under posts so I can add 

if ( $spTopicView->current_Post == 1 ) {

echo show_ad();

}

under spTopicView but now I get an error.

Parse error: syntax error, unexpected T_RETURN in /problem-with-post-edit-buttonome/cpagan/public_html/wp-content/sp-resources/forum-themes/mytheme/templates/spFunctions.php on line 32

Avatar
Christian Pagan
Florida
Member
Free Members
sp_UserOfflineSmall Offline
Jun 3, 2012 - 10:45 pm

Never mind I just copied your code and it put extra numbers so now error gone but ads are still not there!!!

Avatar
Brandon
U.S.
SP Wrangler
Free Members
sp_UserOfflineSmall Offline
Jun 3, 2012 - 11:49 pm

Let's start this kinda over again...

In your spFunctions file add your function and the code for adsense.

function show_ad(){
echo '<center><script type="text/javascript"><!--
google_ad_client = "pub-3637000718131176";
/* 728x90, created 6/1/10 */
google_ad_slot = "3102579232";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>';
}

Put your adsense code in between the first single quote ' and the last ' one.

Then in your spTopicView.php file add this

if ($spTopicView->currentPost == 1) {                                    
if (function_exists('show_ad')) show_ad();
}

Put that below

sp_SectionStart('tagClass=spPostContentSection', 'content');

and above

sp_PostIndexContent('', __sp('Awaiting Moderation'));

That should do it.

Avatar
Christian Pagan
Florida
Member
Free Members
sp_UserOfflineSmall Offline
Jun 4, 2012 - 5:15 pm

I got to this part but than you lost me on put that below and this above. Below and above what???

if ($spTopicView->currentPost == 1) {
     if (function_exists('show_ad')) show_ad();
 }

put that below?????

sp_SectionStart('tagClass=spPostContentSection', 'content');

and above?????

sp_PostIndexContent('', __sp('Awaiting Moderation'));
Avatar
Christian Pagan
Florida
Member
Free Members
sp_UserOfflineSmall Offline
Jun 4, 2012 - 5:16 pm

I mean it works but without the 2 last codes which I am not sure what they do!!

Avatar
Brandon
U.S.
SP Wrangler
Free Members
sp_UserOfflineSmall Offline
Jun 4, 2012 - 8:37 pm

Sorry, In your spTopicView.php file you will see these entries already in it.

sp_SectionStart('tagClass=spPostContentSection', 'content');
 sp_PostIndexContent('', __sp('Awaiting Moderation'));

Put this

if ($spTopicView->currentPost == 1) {
    if (function_exists('show_ad')) show_ad();
 }

between them.

Avatar
OPShots
Member
Free Members
sp_UserOfflineSmall Offline
Jun 11, 2012 - 7:34 pm

Awesome code example...thank you!

I got it working great...what if I wanted to add another ad say after the first and after the third or fourth post?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jun 11, 2012 - 9:56 pm

just change your checks on the current post position...

if ($spTopicView->currentPost == 1 || $spTopicView->currentPost == 3 || $spTopicView->currentPost == 4)

or break it up into separate 'if' statements...

Avatar
Thanakorn Charlee
Nonthaburi, Thailand
Rookie
Free Members
sp_UserOfflineSmall Offline
Aug 11, 2012 - 2:48 pm

Any update?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Aug 11, 2012 - 4:44 pm

Update to what please?

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626