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
Jasneet Gulati
Member
Free Members
sp_UserOfflineSmall Offline
Jun 2, 2012 - 2:31 pm

Yellow Swordfish said
It IS spTopicView.php. You will find the bit Steve suggested in there.

Yes you are right, my apologies.

When I opened it previously it was in notepad. When I opened it in Dreamweaver I found it..mostly.

In my spTopicView.php I found the following:

"sp_InsertBreak();

                    sp_SectionEnd('', 'post');"

and I inserted my echo after this - it worked to some extent. It shows below the first 3 or 4 posts. Not after the first post only.

I could not find this code:

"$spTopicView->current_post==1"

So I'm almost there.

Did you want me to include this bit of code myself?

Thank you Yellow Swordfish - I'm sorry about using Notepad to find the code before, I have learnt from this.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 2, 2012 - 2:59 pm

You need to code that bit yourself. As in:

if ( $spTopicView->current_post == 1 ) {
    .. do your stuff
}

Adding your adsense code within the if test.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Jasneet Gulati
Member
Free Members
sp_UserOfflineSmall Offline
Jun 2, 2012 - 3:24 pm

You're so fast mate! Thank you!

I'm afraid I could not get it to work.

This is what I have - where am I going wrong?:

sp_PostIndexUserSignature('tagClass=spPostUserSignature spCenter&maxHeightBottom=55');
sp_InsertBreak();

sp_ColumnEnd();

sp_InsertBreak();

sp_SectionEnd('', 'post');

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

echo show_ad_camp_3();

}

endwhile; else:
sp_NoPostsInTopicMessage('tagClass=spMessage', __sp('There are no posts in this topic'));
endif;

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 2, 2012 - 4:35 pm

I'm sorry - I should have looked a little harder at Steve's coding suggestion.

That should be: $spTopicView->currentPost

Note - no space and the capital P.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Jasneet Gulati
Member
Free Members
sp_UserOfflineSmall Offline
Jun 2, 2012 - 4:40 pm

SUCCESS!

Thank you very much. What a great service.

I hope you have a great weekend and an even better life, good sir.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 2, 2012 - 4:43 pm

Why thank you! I can't offer you a better wish so I offer you the same!

andy-signature.png
YELLOW
SWORDFISH
Avatar
Christian Pagan
Florida
Member
Free Members
sp_UserOfflineSmall Offline
Jun 3, 2012 - 2:32 pm

Brandon C said
Here is how you can do it.

First create your own theme so any changes you make are not over written by updates. See here on how.

http://codex.simple-press.com/.....g-a-theme/

Since you want to use the adsense code in multiple paces I would create a function for it.

It appears you have seen the files in yourthemes/template folder.  One of the is spFunctions.php.  This is a file that you can add a function to, among other things, that your theme can use.

Create a function for your ad. Let's call it spAddCode

Open the spFuntions.php file up in your editor and at the bottom just above the closing ?> is where you can add the function.

Your function should look something like this.

function spAddCode() {

class="brush-php syntax">spAddCode();

I am trying to add ads and this is what my function looks like 

function show_ad() {
 sp_adsense ('<script type="text/javascript"><!--
google_ad_client = "ca-pub-8654929854924223";
/* Top & Bottom */
google_ad_slot = "2182142041";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>');
}

After doing that I put this code into sp_topic_view.php:

if ( $spTopicView->current_post == 1 ) {
 echo show_ad();
 }

But my add is not showing anywhere. What am I doing wrong.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 3, 2012 - 3:20 pm

There is no such data item as $spTopicView->current_post.

That should be $spTopicView->currentPost - no spaces, capital P

andy-signature.png
YELLOW
SWORDFISH
Avatar
Christian Pagan
Florida
Member
Free Members
sp_UserOfflineSmall Offline
Jun 3, 2012 - 3:40 pm

Ok I have fixed that, but my ad is still not showing up.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jun 3, 2012 - 5:08 pm

not sure what you are trying to do...  if you are going to 'echo' the ad content, the function needs to return something...  and not sure what sp_adsense() is... so something like

function show_ad() {
    return '<script type="text/javascript"><!--
            google_ad_client = "ca-pub-8654929854924223";
            /* Top & Bottom */
            google_ad_slot = "2182142041";
            google_ad_width = 728;
            google_ad_height = 90;
            //-->
            </script>
            <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
            </script>';
}
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