phpBB Ads Ad

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
Exclusive
Registered User
Posts: 345
Joined: Mon Jun 25, 2018 1:33 pm

phpBB Ads Ad

Post by Exclusive » Sat Feb 09, 2019 4:42 pm

I would like to add this type of banner ad in my forum, I discovered it changes each time the page is refreshed, it doesn't show in mobile view, it is not shown in all Viewtopic (s), and where it appears, it shows in the right hand side and the forum rules divides. I wan't exactly this feature.

The below image is what I mean.

phpbb-ads.png

Is this an extension or what? Cause I see has its own class style as

Code: Select all

class=phpbb-ads-ad
Use Search Button to get Instant Results | Follow Forum Rules
Avoid Spams in the forum to prevent banning the offending account. | Visit My Website!

Subscribe to my YouTube Channel!

Get The Best Web Hosting | Buy Cheap Domain Names

User avatar
david63
Jr. Extension Validator
Posts: 15761
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: phpBB Ads Ad

Post by david63 » Sat Feb 09, 2019 4:46 pm

I would guess that it is some custom coding. You can find the phpBB website code on GitHub - don't know if that is in the public repository or not, but you could take a look.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
Lumpy Burgertushie
Registered User
Posts: 66026
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: phpBB Ads Ad

Post by Lumpy Burgertushie » Sat Feb 09, 2019 7:14 pm

no extension, custom coding from phpbb.com

here is how to duplicate it:
It will be best to do this to a custom style and not to prosilver.
If you are already using a custom style make the edit to it.
if not, then create one, or find one you like first.


create your small banner ads. make them small enough to fit the space.


create a new folder in the template folder named ads. put your ad images there.

open: common.css
find:

Code: Select all

/* Horizontal lists
before, add:

Code: Select all

/* Ads (and info-boxes) on viewforum/viewtopic for phpBB.com */
.phpbb-ads {
	margin: 5px 0 10px;
	min-height: 85px;
	overflow: hidden;
	position: relative;
}

.phpbb-ads h2 {
	margin-top: 10px;
	width: 63%;
}

.phpbb-ads div.rules {
	width: 63%;
	margin: 10px 10px 0 0;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}

.phpbb-ads .phpbb-ads-ad {
	display: block;
	position: absolute;
	bottom: 0;
	right: 0;
	max-width: 36%;
}

.phpbb-ads .phpbb-ads-ad img {
	display: block;
	max-width: 100%;
}

@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) {
	.phpbb-ads {
		min-height: auto;
	}

	.phpbb-ads h2 {
		width: auto;
	}

	.phpbb-ads div.rules {
		width: auto;
	}

	.phpbb-ads .phpbb-ads-ad {
		display: none;
	}
}
********************************
open: viewforum_body.html
find:

Code: Select all

<!-- EVENT viewforum_forum_title_before -->
before, add:

Code: Select all

<div class="phpbb-ads">
find:

Code: Select all

<!-- IF S_FORUM_RULES -->
before , add:

Code: Select all

<a href="yourlinkhere" class="phpbb-ads-ad"><img src="{T_THEME_PATH}/ads/your ad banner file here" alt="your alt text here"/></a>
find:

Code: Select all

<!-- IF S_HAS_SUBFORUM -->
before, add:

Code: Select all

</div><!-- /.phpbb-ads -->

************************
open: viewtopic_body.html

find:

Code: Select all

<!-- EVENT viewtopic_topic_title_before -->
before, add:

Code: Select all

<div class="phpbb-ads">
find:

Code: Select all

<!-- IF S_FORUM_RULES -->
before, add:

Code: Select all

<a href="yourlinkhere" class="phpbb-ads-ad"><img src="{T_THEME_PATH}/ads/your ad banner file here" alt="your alt text here"/></a>
find:

Code: Select all

<div class="action-bar bar-top">
before, add:

Code: Select all

</div><!-- /.phpbb-ads -->
save and close all files and upload back to the server. purge cache, refresh browser.

luck,
robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

User avatar
Exclusive
Registered User
Posts: 345
Joined: Mon Jun 25, 2018 1:33 pm

Re: phpBB Ads Ad

Post by Exclusive » Sat Feb 09, 2019 7:45 pm

Yes I did all this before I posted for support here.

This is what I need now, Lemme give it a try, but thanks in advance....
Last edited by Mick on Sun Feb 10, 2019 9:12 am, edited 1 time in total.
Reason: Removed unnecessary quoting.
Use Search Button to get Instant Results | Follow Forum Rules
Avoid Spams in the forum to prevent banning the offending account. | Visit My Website!

Subscribe to my YouTube Channel!

Get The Best Web Hosting | Buy Cheap Domain Names

User avatar
Exclusive
Registered User
Posts: 345
Joined: Mon Jun 25, 2018 1:33 pm

Re: phpBB Ads Ad

Post by Exclusive » Sat Feb 09, 2019 8:11 pm

Thanks bro!

Dear phpBB Community, Please make @Lumpy Burgertushie a top contributor in this community, this guy is so nice and straight forward, always ready to help other users to the core (easy to understand)!

If there was a thanks button in this community, You would have had a million thanks!

Thanks so much!
Use Search Button to get Instant Results | Follow Forum Rules
Avoid Spams in the forum to prevent banning the offending account. | Visit My Website!

Subscribe to my YouTube Channel!

Get The Best Web Hosting | Buy Cheap Domain Names

User avatar
Exclusive
Registered User
Posts: 345
Joined: Mon Jun 25, 2018 1:33 pm

Re: phpBB Ads Ad

Post by Exclusive » Sat Feb 09, 2019 8:13 pm

It also displays in Mobile, how do I disable it too? - [solved, it was a cache problem]

This what I need now:
---------------------------

How can I make the Ads to change, like after every page refresh with there own specified links?

See demo: viewforum.php?f=14
Use Search Button to get Instant Results | Follow Forum Rules
Avoid Spams in the forum to prevent banning the offending account. | Visit My Website!

Subscribe to my YouTube Channel!

Get The Best Web Hosting | Buy Cheap Domain Names

User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 3807
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: phpBB Ads Ad

Post by HiFiKabin » Sun Feb 10, 2019 7:12 pm

Have a look at my Random Banner extension to see how it might be made to work.

User avatar
Exclusive
Registered User
Posts: 345
Joined: Mon Jun 25, 2018 1:33 pm

Re: phpBB Ads Ad

Post by Exclusive » Mon Feb 11, 2019 12:17 pm

HiFiKabin wrote:
Sun Feb 10, 2019 7:12 pm
Have a look at my Random Banner extension to see how it might be made to work.

It seems this extension works only in the header, I don't want to add it to my header.

If you can create such an extension, that means you can help me out as it is similar to what I'm in need of.
Use Search Button to get Instant Results | Follow Forum Rules
Avoid Spams in the forum to prevent banning the offending account. | Visit My Website!

Subscribe to my YouTube Channel!

Get The Best Web Hosting | Buy Cheap Domain Names

User avatar
HiFiKabin
Community Team Member
Community Team Member
Posts: 3807
Joined: Wed May 14, 2014 9:10 am
Location: Swearing at the PC, UK
Name: James
Contact:

Re: phpBB Ads Ad

Post by HiFiKabin » Mon Feb 11, 2019 12:29 pm

I know the extension will only work in the header. I was using it as an example of the code you could use.

It might be made into an extension but it is a lot of work just for the one request.

User avatar
mrgoldy
Jr. Extension Validator
Posts: 946
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: phpBB Ads Ad

Post by mrgoldy » Tue Feb 12, 2019 11:19 am

Displaying a random image will require a twig function: random().
This picks a random item from an array. This is actually random, so there is no way to control how often a certain item should be displayed in regards to others. If you're unlucky, the same item displays X times in a row. But I suppose that's "without saying" if you use some kind of random function.

Replace this:

Code: Select all

<a href="yourlinkhere" class="phpbb-ads-ad"><img src="{T_THEME_PATH}/ads/your ad banner file here" alt="your alt text here"/></a>
with

Code: Select all

{% set ads = ['image1.png', 'image2.png', 'image3.png'] %}
<a href="yourlinkhere" class="phpbb-ads-ad"><img src="{T_THEME_PATH}/ads/{{ random(ads) }}" alt="your alt text here"/></a>
This will however only change your image, not the link and not the alt text.
If you also want those to change according to the image, you'll have to do a bit more coding:

Code: Select all

{% set ads =
	[
		{
			'alt': 'Image one',
			'src': 'image1.png',
			'url': 'http://example.com',
		},
		{
			'alt': 'Image two',
			'src': 'image2.png',
			'url': 'http://example.com',
		},
		{
			'alt': 'Image three',
			'src': 'image3.png',
			'url': 'http://example.com',
		},
	]
%}
{% set ad = random(ads) %}

<a href="{{ ad.url }}" class="phpbb-ads-ad"><img src="{T_THEME_PATH}/ads/{{ ad.src }}" alt="{{ ad.alt }}"/></a>
As Lumpy already somewhat mentioned, but I am just going to restate them:
Any custom coding you do, you should write down somewhere all the steps and code you did the achieve it. As there is a good chance you might have to re-do them if you update / upgrade your phpBB (or style) version.

And as a side note, phpBB also has an official extension Advertisement Management, which offers a lot of possibilities and locations aswell. I do however believe, that the location in question is not available. But still something to consider as it would avoid having to modify core files and allows you to define a priority on how big the chance should be to display this ad in regards to others. The same functionality can be achieved by adding the same advertisement multiple times to the forementioned array, to increase the chance of it being picked but it is "less clean".

Anyway, hope this helps and enjoy! :+1:
phpBB Studio / ''Proud member of the Studio"

User avatar
Exclusive
Registered User
Posts: 345
Joined: Mon Jun 25, 2018 1:33 pm

Re: phpBB Ads Ad

Post by Exclusive » Tue Feb 12, 2019 2:16 pm

mrgoldy wrote:
Tue Feb 12, 2019 11:19 am
If you also want those to change according to the image, you'll have to do a bit more coding:

Code: Select all

{% set ads =
	[
		{
			'alt': 'Image one',
			'src': 'image1.png',
			'url': 'http://example.com',
		},
		{
			'alt': 'Image two',
			'src': 'image2.png',
			'url': 'http://example.com',
		},
		{
			'alt': 'Image three',
			'src': 'image3.png',
			'url': 'http://example.com',
		},
	]
%}
{% set ad = random(ads) %}

<a href="{{ ad.url }}" class="phpbb-ads-ad"><img src="{T_THEME_PATH}/ads/{{ ad.src }}" alt="{{ ad.alt }}"/></a>

I tried this, but it didn't work out. Is there something missing?
Use Search Button to get Instant Results | Follow Forum Rules
Avoid Spams in the forum to prevent banning the offending account. | Visit My Website!

Subscribe to my YouTube Channel!

Get The Best Web Hosting | Buy Cheap Domain Names

User avatar
mrgoldy
Jr. Extension Validator
Posts: 946
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: phpBB Ads Ad

Post by mrgoldy » Tue Feb 12, 2019 3:16 pm

"It didn't work out" is not a very descriptive error.

Is the image not showing, is the url or alt tag wrong?
Does twig throw an error? Shouldn't be as the code is valid.
phpBB Studio / ''Proud member of the Studio"

User avatar
Exclusive
Registered User
Posts: 345
Joined: Mon Jun 25, 2018 1:33 pm

Re: phpBB Ads Ad

Post by Exclusive » Sat Apr 20, 2019 2:21 am

mrgoldy wrote:
Tue Feb 12, 2019 3:16 pm
"It didn't work out" is not a very descriptive error.

Is the image not showing, is the url or alt tag wrong?
Does twig throw an error? Shouldn't be as the code is valid.
I've done it, thanks!
Use Search Button to get Instant Results | Follow Forum Rules
Avoid Spams in the forum to prevent banning the offending account. | Visit My Website!

Subscribe to my YouTube Channel!

Get The Best Web Hosting | Buy Cheap Domain Names

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: Brf, janus_zonstraal, Lumpy Burgertushie and 4 guests