View Full Version : How to add php code to a template?
shri
Mon 1st May '00, 5:48pm
Hi,
I want to show a banner on top of every page.
This would mean that I'd have to modify the "header" template to include the code.
How can I call my banner routines from phpAds?
<? require("/phpads2/top.php3"); ?>
Which does not seem to work by the way.
Shri
John
Mon 1st May '00, 6:26pm
In the general settings control panel, there is an option to parse the header as php code, down the bottom with the image settings.
Try putting this as your header:
$header="<p>This is a header!</p><a name=\"top\"></a></p>";
require("phpads.php");
$header.=doadcode($myad);
$header.="<p>That was an advert. Please click!</p>";
John
shri
Mon 1st May '00, 7:02pm
Simply Brilliant! :) :)
shri
Mon 1st May '00, 7:59pm
Something may be broken.
I've edited the templates to have header set as follows
$header="Test";
require("/usr/local/apache/sites/gandmasti.net/htdocs/phpads2/top.php3");
On http://www.gandmasti.net/forum I get an error which says
Parse error: parse error in Unknown on line 0
There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.
An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.
We apologise for any inconvenience.
John
Mon 1st May '00, 10:20pm
OK - just a thought. I've a feeling that there may have been a bug in the parse as php in a version a while ago - I did not think that it was in the release version, but it might have been.
Remove the semi colon from the end of the last line and see if that helps.
I didn't get that database error though.
Please replace the copyright notice in the footer. Thanks :)
John
shri
Mon 1st May '00, 10:26pm
The copyright will be replaced if / when the board goes into production. It is a test environment. Jeez..
Just
$header="Test";
or
$header="Test"
still produce errors.
This is released code downloaded on Saturday.
[Edited by shri on 05-02-2000 at 10:28 AM]
shri
Mon 1st May '00, 10:42pm
For whats its worth. The system is on PHP4 RC 1 and Zend Optimizer Beta 2 (the optimiser does not make a diff if turned on or off).
John
Mon 1st May '00, 11:01pm
OK. There is a new version out now. I'm just about to announce it.
In the global.php in the main forum directory, find line 623, and check that it looks like this:
// parse header ##################
if ($useadvheader==1) {
eval(gettemplate("header",0));
} else {
eval("\$header = \"".gettemplate("header")."\";");
}
if ($useadvfooter==1) {
eval(gettemplate("footer",0));
} else {
eval("\$footer = \"".gettemplate("footer")."\";");
}
John
shri
Tue 2nd May '00, 10:43pm
John,
Looks like when I include another php application code in the headers (specifically phpAds) some variables are getting screwed up in the vB code.
This is what I get in the mail.
Database error in vBulletin: Invalid SQL: SELECT
canview,cansearch,canemail,canpostnew,canreply,can adminedit,canedit,candelete,can
openclose,canmove,cancontrolpanel FROM usergroup WHERE usergroupid=7
mysql error: Table 'gmads2.usergroup' doesn't exist
mysql error number: 1146
Date: Wednesday 03rd of May 2000 09:33:29 AM
Script: /forum/index.php
Referer: http://gandmasti.net/forum/admin/index.php?action=head
gmads2 is the database where I store my adverts. Perhaps this might make sense now...
Got other problems also when I turn on the useadvheader variable.. will log them later.
[Edited by shri on 05-03-2000 at 10:45 AM]
John
Wed 3rd May '00, 1:46am
OK - add this line to the end of your header code:
$DB_site->query("USE $dbname");
John
Martin
Wed 3rd May '00, 3:00am
after you and john get it sorted out, can you ost the code need in a single post?
I was thinking about PHPAds as our server for this:)
werehere
Wed 3rd May '00, 3:14am
hey, shri...
after you and john get it sorted out, can you ost the code need in a single post?
I was thinking about PHPAds as our server for this
Yes please do:)
Has anyone installed and tested the PHPAds that was released yesterday;)
Martin
Wed 3rd May '00, 5:26am
I haven't yet, I'm still waiting on becca to come over and by the proggie so I can set it up our server. What are the diffs?
The one thing I know I like about PHPAds is that I can run the full adcode for all the different services we use instead of the simple link code. That will definitely help with getting more accurate stats and delivery of Rich Media ads.
shri
Wed 3rd May '00, 10:39am
John,
Your line of code worked. I do not get any more database errors and the advert displays. (but wait, there is a catch to this) :)
Here's what I put in the header template.
$header="<center>";
require("/usr/local/apache/sites/gandmasti.net/htdocs/phpads/config.inc.php3");
require("/usr/local/apache/sites/gandmasti.net/htdocs/phpads/view.inc.php3");
require("/usr/local/apache/sites/gandmasti.net/htdocs/phpads/acl.inc.php3");
$header.=view("paid");
$DB_site->query("USE $dbname");
$header.="</center>";
Now here is what I have in my forumhome template.
{htmldoctype}
<HTML>
<HEAD><TITLE>$bbtitle</title>
$cssinclude
</head>
<body>
$header
Now here is the output....
<!-------GM - College Ad Spot/AdFlight Ad Server 2.5.1 Begin Code-------->
(shri-- deleted ad code)
<!-------GM - College Ad Spot/AdFlight Ad Server 2.5.1 End Code---------------> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>Indian Jokes, News and Links on Gandmasti.Net </title>
<STYLE type=text/css>
The output of $header shows up before the output of the template.
John
Wed 3rd May '00, 6:07pm
Your ad scripts - do they echo the code, or do they return it in a variable. It is neccessary for them to return the code in a variable for it to work here.
This is what I suggested earlier:
require("phpads.php");
$header.=doadcode($myad);
John
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.