How do add additional PHP-code (banner rotation)?

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Adagio
Registered User
Posts: 81
Joined: Mon Sep 24, 2001 7:32 pm
Location: Berlin, Germany
Contact:

How do add additional PHP-code (banner rotation)?

Post by Adagio »

Hi,

in my phpBB2 forums, I would like to include a banner rotation script. To show the banner/ads, I need to insert this piece of code:

Code: Select all

<?
require('path/to/ledads/ad_class.php');
echo $pla_class->adcode( );
?>
The problem is, that this doesn't work when I include it directly into the header-template of phpBB.

How can I add this? I am not very familiar with PHP-templates ... :cry:
My software never has bugs. It just develops random features.
User avatar
roly
Registered User
Posts: 775
Joined: Fri Jan 04, 2002 7:13 am
Location: Australia

Post by roly »

Adagio
Registered User
Posts: 81
Joined: Mon Sep 24, 2001 7:32 pm
Location: Berlin, Germany
Contact:

Post by Adagio »

Uhm, well, this would be another solution ... but I would like to use this as "real" template, tag, e.g. when I include the placeholder {BANNER} into anny template (e.g. the header), phpBB should build in the ad/banner at this point ... is this very difficult to include?
My software never has bugs. It just develops random features.
User avatar
roly
Registered User
Posts: 775
Joined: Fri Jan 04, 2002 7:13 am
Location: Australia

Post by roly »

Adagio wrote: Uhm, well, this would be another solution ... but I would like to use this as "real" template, tag, e.g. when I include the placeholder {BANNER} into anny template (e.g. the header), phpBB should build in the ad/banner at this point ... is this very difficult to include?

http://www.phpbb.com/mods/downloads/act ... n=go&id=36
Adagio
Registered User
Posts: 81
Joined: Mon Sep 24, 2001 7:32 pm
Location: Berlin, Germany
Contact:

Post by Adagio »

Erm, yes, you posted this link before. This MOD allows simple php to be inserted into the .tpl files.

But I don't want to use any PHP Code at all in the templates. I would like to use a placeholder like {BANNER} for this, just like {T_BODY_TEXT}, {U_SEARCH} etc. ...
My software never has bugs. It just develops random features.
User avatar
roly
Registered User
Posts: 775
Joined: Fri Jan 04, 2002 7:13 am
Location: Australia

Post by roly »

Adagio wrote: Erm, yes, you posted this link before. This MOD allows simple php to be inserted into the .tpl files.

But I don't want to use any PHP Code at all in the templates. I would like to use a placeholder like {BANNER} for this, just like {T_BODY_TEXT}, {U_SEARCH} etc. ...

http://www.phpbb.com/mods/downloads/act ... n=go&id=36 just use that
Adagio
Registered User
Posts: 81
Joined: Mon Sep 24, 2001 7:32 pm
Location: Berlin, Germany
Contact:

Post by Adagio »

Are you serious? As I've tried to say before, I don't want to use this kind of solution ... am I talking to a wall? :roll:
My software never has bugs. It just develops random features.
User avatar
chAos
Former Team Member
Posts: 4032
Joined: Wed Jan 16, 2002 7:05 am
Location: Seattle, WA, US

Post by chAos »

i am probably wrong, but i might not be.

the {THINGS}s are defined in languages/lang_xxx/lang_main.php

just a guess about that.
erossetto
Registered User
Posts: 217
Joined: Mon Dec 17, 2001 12:59 pm
Location: .ar

Post by erossetto »

Well well well... we have a clean answer here... :wink:

You'll need to create a 'mod', just:
Require your file somewhere and....

Code: Select all

$template->assign_vars(array(
'SITENAME' => $board_config['sitename'], 
....
'BANNER' => $banner_var_returned_by_include,
....
I think that will work, but tell me if you need help. :D

/ my english it's so bad that I need to show an example :oops:
Last edited by erossetto on Tue Apr 30, 2002 11:54 am, edited 3 times in total.
^^^^
erossetto
Registered User
Posts: 217
Joined: Mon Dec 17, 2001 12:59 pm
Location: .ar

Post by erossetto »

ChAoS wrote: i am probably wrong, but i might not be.

the {THINGS}s are defined in languages/lang_xxx/lang_main.php

just a guess about that.

Yep, you are wrong. :D
^^^^
Adagio
Registered User
Posts: 81
Joined: Mon Sep 24, 2001 7:32 pm
Location: Berlin, Germany
Contact:

Post by Adagio »

erossetto wrote: Well well well... we have a clean answer here... :wink:

You'll need to create a 'mod', just:

'Require' the file (your ad class) somewhere in page_header.php
Add a new template var in page_header.php called banner that calls the var that returns your class. (obviously in $template->assign_vars array)

I think that will work, but tell me if you need help. :D


Yes, this is exactly what I want to do ... but I have no idea how this works, or how to implement this. I am not very familiar with php templates ...

Uhm, would it be too much asking you to do it for me? We could do this via email or ICQ, if you don't mind :)
My software never has bugs. It just develops random features.
erossetto
Registered User
Posts: 217
Joined: Mon Dec 17, 2001 12:59 pm
Location: .ar

Post by erossetto »

I've just edited my post. :D
^^^^
Adagio
Registered User
Posts: 81
Joined: Mon Sep 24, 2001 7:32 pm
Location: Berlin, Germany
Contact:

Post by Adagio »

Ah, I see ... thanks ;)

One more problem for me:

Code: Select all

'BANNER' => $banner_var_returned_by_include,
Where do I get this variable from? The code that is needed to be executed is this one:

Code: Select all

<?php
require('path/to/ledads/ad_class.php');
echo $pla_class->adcode( );
?>
Do I have to include this code anywhere in page_header.php? Or what do I need to add?

Sorry for my dumb questions ... :cry:
My software never has bugs. It just develops random features.
erossetto
Registered User
Posts: 217
Joined: Mon Dec 17, 2001 12:59 pm
Location: .ar

Post by erossetto »

Code: Select all

## require file
require('path/to/ledads/ad_class.php'); 
## set var
$banner = $pla_class->adcode( );
## add new 'template' var
'BANNER' => $banner,
See now? :?:
^^^^
erossetto
Registered User
Posts: 217
Joined: Mon Dec 17, 2001 12:59 pm
Location: .ar

Post by erossetto »

This is OT
Personally I prefer phpAdsNew and include banners using iframes or javascript directly from the templates (tpl - with no phpBB modifications)...
^^^^
Locked

Return to “2.0.x Support Forum”