Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
php echo statement to output the adsense code
Avatar
Craig Pimbley
Member
Free Members
sp_UserOfflineSmall Offline
Oct 24, 2012 - 3:15 pm

I want to add a couple 728x90 google ads to my forum.

I think I know what to do if it just involves adding the google code. But on a post in this thread "https://simple-press.com/support-forum/sp5-coding-questions/adsense-code/" you mention "just use the php echo statement to output the adsense code".

 

How do I echo it / will it make any difference if I just add the code to the places I wish for them to appear?

Mr Papa said
you can just stick it in the template file for the sp theme you are using, checking for $spTopicView->current_post==1, after the inner post loop...

right after these

                        sp_InsertBreak();

                    sp_SectionEnd('', 'post');

just use the php echo statement to output the adsense code... you might want to style it...

as always, we recommend you make your own sp theme before editing ours to prevent losing changes on upgrade... http://codex.simple-press.com/.....g-a-theme/

 

 Many Thanks

Craig

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Oct 24, 2012 - 4:52 pm

It depends what form the code is that you need to insert. Normally you would just use that - an echo statement with the following text in quotes - as most adSense code I have seen is javascript. So just echo 'xxxx'; where the xxxx is the adsense code.

However you have to check for quotes within the adsense code. If the adsense code contains any single quotes then use double quotes with the echo and visa versa. And note the semi-colon at the end...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Craig Pimbley
Member
Free Members
sp_UserOfflineSmall Offline
Oct 24, 2012 - 5:21 pm

I don't mean to be a pain but I still don't understand? I don't know what an echo is?

Thank you for your help, I really do appreciate it and the quick reply's.

Craig

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 24, 2012 - 8:51 pm

http://php.net/manual/en/funct.....n.echo.php

so something like:

echo 'your adsense code goes between these single quotes. make sure no single quotes in your adsense code or switch one of them to double quotes';

Avatar
Craig Pimbley
Member
Free Members
sp_UserOfflineSmall Offline
Oct 25, 2012 - 10:46 am

Ahh, I get it now. Thank you.

However I do still have one problem. I can't seem to locate the current_post==1?

you can just stick it in the template file for the sp theme you are using, checking for $spTopicView->current_post==1, after the inner post loop…

right after these

                        sp_InsertBreak();

                    sp_SectionEnd('', 'post');

just use the php echo statement to output the adsense code… you might want to style it…

I have found

sp_ColumnEnd();

                                sp_InsertBreak();

                            sp_SectionEnd('', 'post');

But when I add it here it shows an ad under every post.

 

Thanks again for all your help :D

Avatar
Brandon
U.S.
SP Wrangler
Free Members
sp_UserOfflineSmall Offline
Oct 25, 2012 - 12:17 pm

The code is not already there.

What you want to do is add it to check and see if first post.

Here is a an example that shows how.

https://simple-press.com/suppo.....2/#p109115

 

but use the way shown on post #14 there.

Avatar
Craig Pimbley
Member
Free Members
sp_UserOfflineSmall Offline
Oct 25, 2012 - 12:49 pm

Will you not be making a plugin for this? Mingle forums has a bit where you just paste the code, will something like this ever be available here?

I'm no good at all this coding stuff.

Thanks for your help.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Oct 25, 2012 - 2:39 pm

The best I can say at the moment is - possibly. Time would be the factor here...

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: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625