Support Forum

php echo statement to output the adsense code

CP Craig Pimbley
Craig Pimbley
Member

I want to add a couple 728×90 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/codex/themes/theme-basics/creating-a-theme/

 

 Many Thanks

Craig

7 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

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…

CP Craig Pimbley
Craig Pimbley
Member

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

MP Mr Papa
Mr Papa
Member

http://php.net/manual/en/function.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’;

CP Craig Pimbley
Craig Pimbley
Member

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

BR Brandon
Brandon
Member

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/support-forum/sp5-coding-questions/adsense-code/page-2/#p109115

 

but use the way shown on post #14 there.

CP Craig Pimbley
Craig Pimbley
Member

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.

YS Yellow Swordfish
Yellow Swordfish
Member

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