Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2013-01-29 03:21:17

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Ad after first post (Guests Only)

I would like to put an ad placement under the first post (for Guests Only).

I am just after the code and where to place it in the file, I can do the CSS etc myself.

Using Fluxbb 1.5.2

(I have looked at the mods and nothing suits my needs, i.e. I dont want the ad displayed in a post.)

Thanks.

Offline

#2 2013-01-29 13:05:59

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: Ad after first post (Guests Only)

OK, so I've been working on a piece of code which echo's text after the first post for guests only.

The problem I'm now having is I dont know how to echo the Google Adsence javascript, it comes up with an error. I'm sure my code just needs a tweak, so if anyone can help me out it would be appreciated.

<?php if ($pun_user['is_guest'] == '1' && $post_count == '1') echo '<div style="clear:both; margin-bottom: 3px;"><div class="adblock-afterfirstpost">'.hello.'</div></div>'; ?>

Offline

#3 2013-01-30 04:42:09

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: Ad after first post (Guests Only)

Alright, I have now been able to echo the Google Adsence code but I cant seem to style it. If I style outside of <?php ?> the styling shows up after every post. So I need to somehow incorporate the div somewhere in my code so that it only shows after the first post.

I'm not the best with PHP so I really need some help with this.

Current Code

<?php if ($pun_user['is_guest'] == '1' && $post_count == '1') echo '
<script type="text/javascript"><!--
google_ad_client = "ca-pub-7337445176362285";
/* After First Post */
google_ad_slot = "9372247332";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>' ?>

Offline

#4 2013-01-30 21:58:56

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 5,929
Website

Re: Ad after first post (Guests Only)

First of all, echoing a long string like that should not be done via PHP. You could do this instead:

<?php if ($pun_user['is_guest'] && $post_count == 1): ?>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-7337445176362285";
/* After First Post */
google_ad_slot = "9372247332";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php endif; ?>

Apart from that, I'm afraid I don't understand the question. What do you mean by styling outside of the PHP tags and which "styling shows up"?


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#5 2013-01-31 01:07:25

quaker
Member
From: USA
Registered: 2008-05-09
Posts: 88
Website

Re: Ad after first post (Guests Only)

As I understand it . You can't place the code into the main.tpl file. You would have to place the code into the Viewtopic.php file inside of the loop.
Q


My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Offline

#6 2013-01-31 05:40:13

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: Ad after first post (Guests Only)

I just wanted to be able to style the ad placement, rather than have it left aligned with no padding. It was pretty simple, I ended up using the code below in viewtopic.php. It works as expected.

<?php if ($pun_user['is_guest'] == '1' && $post_count == '1') echo '
<div style="clear:both; margin-bottom: 3px;"><div class="adblock-afterfirstpost"><script type="text/javascript"><!--
google_ad_client = "ca-pub-7337445176362285";
/* After First Post */
google_ad_slot = "9372247332";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>'; ?>

Fanz I tried your code and it threw an error about the php endif. Is there something wrong with the code you provided?

Offline

#7 2013-01-31 12:13:32

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 5,929
Website

Re: Ad after first post (Guests Only)

I don't think it was wrong. Was there more PHP code after my code? If so, remove the closing PHP tag.

But I'm glad you got it working. smile


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#8 2013-02-01 01:25:55

quaker
Member
From: USA
Registered: 2008-05-09
Posts: 88
Website

Re: Ad after first post (Guests Only)

How about a simple php include file?
<?php include "guest-ads.php" ;?>
Place your Adsense stuff in a new php file called guest-ads.php

Sorry, trying to catch up on my php functions again of fluxbb. Been over a 1yr! Since I did anything with fluxbb.

Q


My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Offline

#9 2013-02-01 01:27:31

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 5,929
Website

Re: Ad after first post (Guests Only)

Glad to have you back. smile


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#10 2013-02-01 01:29:07

quaker
Member
From: USA
Registered: 2008-05-09
Posts: 88
Website

Re: Ad after first post (Guests Only)

Thanks... I'm trying to create a portal page.. grrr.. I got to learn the new tpl system..lol.


My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Offline

#11 2013-02-01 01:52:51

Franz
Lead developer
From: Germany
Registered: 2008-05-13
Posts: 5,929
Website

Re: Ad after first post (Guests Only)

I believe the Victory style is using that quite a bit.

You seem to have already discovered it, but you might wanna check out their code. smile


fluxbb.de | develoPHP

"As code is more often read than written it's really important to write clean code."

Offline

#12 2013-02-03 04:26:04

Squiggles
Member
Registered: 2012-12-14
Posts: 278

Re: Ad after first post (Guests Only)

OK, so I have now switched over to the following code

<?php if ($pun_user['is_guest'] == '1' && $post_count == '1')
{
include PUN_ROOT.'ads/ad-after-first-post.php';
}
?>

I have now put my Google Ad code (includng styling) in a file called ad-after-first-post.php

Thanks for your help guys.

Offline

Board footer

Powered by FluxBB 1.5.7