Add a custom banner/post inside an active thread
4 posters
Page 1 of 1
Add a custom banner/post inside an active thread
In my threads I want to be able to add custom content automatically. Similiar to the ad in the screen shot. In his forum, he is running phpbb3 as I am (www.txsoccer.net), and every topic, there is a banner ad in the thread content. Is that something I can add, and if so, any direction on how? The example is a google ad, but I'd like to be able to ad my own content as well, upcoming events and such.
This is not my site, but just an example of what I am trying to do....
This is not my site, but just an example of what I am trying to do....
Re: Add a custom banner/post inside an active thread
I checked these out, the advertising poster is close. It puts it at the end of the last topic. I would prefer it somewhere in the thread on each page, but I gave it a shot anyway. It was for phpbb2 and I am running phpbb3 and the templates are a little different and although I got close, I am just not good enough to make the customizations to make it work.
Re: Add a custom banner/post inside an active thread
You can do this using a Javascript:
Title: Ads Between Posts
Placement: In all the pages
You can set as many ads as you want, which will be picked at random every time. See the start of the code for more info.
After that you can also modify some properties of the ads via CSS using .post-custom-ad
For example:
If you have any trouble with this, please ask.
- Code:
// Javascript - Ads Between Posts
$(function(){
// Add something after every 'n' posts (in every page), set here this number:
var n = 1;
// Here you can set different possible contents (Ads) available in your topics, as many as you want:
var contents = [
'<a href="http://help.forumotion.com/"><img style="background-color:#105289;" src="https://i62.servimg.com/u/f62/09/00/43/96/xppj910.png" alt="The forum of the forums"></a>',
'<a href="http://help.forumotion.com/"><img style="background-color:#259666;" src="https://i62.servimg.com/u/f62/09/00/43/96/xppj910.png" alt="The forum of the forums"></a>',
'<a href="http://help.forumotion.com/"><img style="background-color:#845615;" src="https://i62.servimg.com/u/f62/09/00/43/96/xppj910.png" alt="The forum of the forums"></a>',
'<div style="padding:8px;background-color:#c00;color:#fff;font-weight:600;border-radius:8px;">Please don\'t forget to read the FORUM RULES!</div>'
];
var posts_ary = $('.post'), i, current_post;
for (i = 0; (i < Math.floor(parseFloat(posts_ary.length) / n)); i++){
current_post = posts_ary[(i * n) + (n - 1)];
// Create the Ad DIV
var new_ad = document.createElement('DIV');
$(new_ad).addClass("post-custom-ad");
// Pick one of the possible contents (random)
new_ad.innerHTML = contents[Math.floor(Math.random() * contents.length)];
current_post.after(new_ad);
}
});
Title: Ads Between Posts
Placement: In all the pages
You can set as many ads as you want, which will be picked at random every time. See the start of the code for more info.
- Spoiler:
How to add a linked image as a content
Each one of those large lines in the code section "contents" is a different Ad and can have any inner HTML that you want.
I added some as examples.
The most common Ad format is the linked image, which would have this format:
'<a href="SITE LINK"><img src="IMAGE LINK" title="TEXT WHEN YOU HOVER"></a>'
After that you can also modify some properties of the ads via CSS using .post-custom-ad
For example:
- Code:
.post-custom-ad {
text-align: center;
margin-bottom: 4px;
}
If you have any trouble with this, please ask.
Wecoc- Forumember
- Posts : 144
Reputation : 111
Language : Catalan, Spanish, English
Re: Add a custom banner/post inside an active thread
OK, I was able to make this work with the common type of ads, but not with a google ad. Is the script different if adding a google ad?
Re: Add a custom banner/post inside an active thread
When you say ads, what exactly do you mean? If you mean your own Google ads, you have to remove Forumotion's ads first.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: Add a custom banner/post inside an active thread
Here is my current code, it doesn't seem to be working. Have it saved and set to run on every page. Can you tell me what I am missing? Not a coder, so I am winging things here...
- Code:
// Javascript - Ads Between Posts
$(function(){
// Add something after every 'n' posts (in every page), set here this number:
var n = 1;
// Here you can set different possible contents (Ads) available in your topics, as many as you want:
var contents = [
'<a href="<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-3954380481016944"
data-ad-slot="9400830262"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></a>
];
var posts_ary = $('.post'), i, current_post;
for (i = 0; (i < Math.floor(parseFloat(posts_ary.length) / n)); i++){
current_post = posts_ary[(i * n) + (n - 1)];
// Create the Ad DIV
var new_ad = document.createElement('DIV');
$(new_ad).addClass("post-custom-ad");
// Pick one of the possible contents (random)
new_ad.innerHTML = contents[Math.floor(Math.random() * contents.length)];
current_post.after(new_ad);
}
});
Similar topics
» I would like a transparent Banner similiar to the banner inside of the link given below! Thanks
» Custom Thread Prefix Button with a dropdown selection
» Today's active post bug
» Navbar inside banner section
» Background image for user's post inside a topic
» Custom Thread Prefix Button with a dropdown selection
» Today's active post bug
» Navbar inside banner section
» Background image for user's post inside a topic
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum