View Full Version : php include for adserver
joand
07-16-2005, 04:59 PM
I have read everything I can find here, but I cannot figure out how to do this (I am not a PHP guru). I need to incorporate an adserver into the site.
It requires the following php code to be added to the start of the file (which I added to the index.php file:
require("$DOCUMENT_ROOT/adserver/config.inc.php3");
require("$DOCUMENT_ROOT/adserver/view.inc.php3");
and then at the point where you want the ad:
view("bannerid");
This is where I am stuck. I tried adding this to the header html panel and adding an .htaccess file as suggested in the forum (AddHandler application/x-httpd-php .html .htm), but that did not work.
I believe I have to add something to the header php file and then something else to the html file - but I haven't a clue where to start.
Can you please help??
Thank you,
Joan
Jordie (Interspire Staff)
07-18-2005, 02:17 AM
Hi Joan,
Find this section of code in your pageheader.php file // Parse the panel of tokens, etc
$GLOBALS["HomePagePath"] = $GLOBALS["AL_CFG"]["siteURL"];
$GLOBALS["WebSiteName"] = $GLOBALS["AL_CFG"]["siteName"];
$GLOBALS["SitePages"] = $this->GetSitePages();
$GLOBALS["SiteMapPath"] = sprintf("%s/sitemap.php", $GLOBALS["AL_CFG"]["siteURL"]);
$GLOBALS["SyndicatePath"] = sprintf("%s/syndicate.php", $GLOBALS["AL_CFG"]["siteURL"]);
then add this line underneath
$GLOBALS["ShowBanner"] = view("bannerid");
add require("$DOCUMENT_ROOT/adserver/config.inc.php3");
require("$DOCUMENT_ROOT/adserver/view.inc.php3");
to the init.php file in the base directory, then put %%ShowBanner%% in the pageheader.html file where you want the banner to show up.
Let me know how it goes!
joand
07-19-2005, 01:26 PM
Hi Jordie,
It goes fairly good....
I tried putting the adserver code in the init.php file but it didn't work (the html page came out blank) but it does work in the index.php file. Are there any pages that do not use the index.php file that use the pageheader file?
When I put %%ShowBanner%% in the html file, the banner did show up on the page - but at the very top of the page, and %%ShowBanner%% showed up as text where the banner should be. I looked at the original pageheader.html file and the other %%'s looked like %%GOLBAL_whatever%% so I changed it to %%GLOBAL_ShowBanner%%. The banner still shows up at the top of the page, but now a "1" shows up where %%GLOBAL_ShowBanner%% was. You can see the result here: http://www.bramptonschools.com/articles/ Where the "1" is beside BramptonSchools.com is where the banner is supposed to be.
Joan
joand
07-21-2005, 01:19 PM
Anyone have any ideas what is wrong and how I can fix it????
Joan
Jordie (Interspire Staff)
07-25-2005, 04:30 AM
Does the view(); function output the ad or return it? If it outputs it, then that is your problem. You will need to alter it to return it so it can be placed in a variable.
I can quickly do this for you if you send over the 2 php include files. (only if this is the actual case, I can't do extensive modification)
joand
07-25-2005, 02:58 PM
Hmm - well it echoes it, I guess that means it outputs it. Attached is the view.inc file - you can take a quick look at it and see. The config file just contains the mySql user, server, password stuff, so I don't want to send it through the forum.
I recently installed a vBulletin board for the same network with the same adserver. In that case I was able to use Output Buffering to incorporate the banner code - I was wondering if that might be able to be done here (if you can't easily modify the view.inc file).
In that case, I created a php file just containing the
view("bannerid");
and then included the following in the "php start" file:
ob_start();
include('/path/to/phpincludefile.php');
$banner_header = ob_get_contents();
ob_end_clean();
Then where I wanted the banner to show up I put $banner_header.
I don't know how/if that can be translated to the %%GLOBALS%% thing.
Joan
Jordie (Interspire Staff)
07-26-2005, 04:07 AM
Hi,
Yes you are right, put this in pageheader.php
ob_start();
view("bannerid");
$GLOBALS["ShowBanner"] = ob_get_contents();
ob_end_clean();
joand
07-26-2005, 03:50 PM
Thank you! Thank you! Thank you!
Joan