View Full Version : easy one: how to parse PHP code on page gen?
webghey
06-14-2005, 08:51 PM
OK so I have a forum and I'm trying to modify my ad column. Basically I can edit the code for this column, which is similar to this:
<br />
<table cellpadding="$stylevar[outerborderwidth]" cellspacing="0" border="0" class="tborder" width="$stylevar[tablewidth]" align="center">
<tr>
<td>
<table cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" style="width:100%">
<tr align="center">
<td class="tcat"><span class="smallfont"><b>Advertisement</b></span></td>
</tr>
<tr>
<td class="alt1" align="center">
<!-- ads go here -->
</td></tr></table></td>
</tr>
</table>
Note the "ads go here" html comment.
So I'd like to include a PHP script I wrote which will (for the sake of info here) randomly rotate a few ads. Easy script, no big deal.
<?php require("/forums/random.php"); ?>
Obviously the result of putting this in the above HTML code/template is that the PHP is not parsed. I imagine this is due to post-PHP/outside-of-PHP parsing which occurs when a page is generated with vbulletin eh?
Is there a work around for this, or will I need to resort to rewriting my handy script in javascript?
Any help is appreciated!! =)
Logikos
06-14-2005, 09:07 PM
add: require_once('./random.php'); to you PHPINCLUDE_Start template.
webghey
06-14-2005, 09:23 PM
OK that's cool, but the PHP code I wrote is designed to be placed in the ad column itself, not anywhere else. It actively writes html to the client on page generation...
Even if I wrap the entire PHP code page in a function, I can't execute the function call from the ad column template since the PHP isn't parsed.
Any further ideas? Or did I misunderstand your suggestion?
Thanks!
Logikos
06-14-2005, 09:25 PM
POST your .PHP page here, and i'll change it so it can use the templates. BTW https://vborg.vbsupport.ru/showthread.php?t=83052
webghey
06-14-2005, 09:37 PM
ok, this is it
<!-- google adsense code -->
<script type="text/javascript">
<!--
google_ad_client = "pub-0145864971037889";
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = "160x600_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "990000";
google_color_bg = "FFFFFF";
google_color_link = "660000";
google_color_url = "000000";
google_color_text = "000000";
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<!-- /google adsense code -->
<p>
<!-- 'other' ads code -->
<?php
// this is the array of ads; put the HREF and IMG tags on one line so as to keep spacing issues at bay.
// you can add more wherever you want, but make sure the LAST element of this array has no comma afterwards.
// ALSO IMPORTANT: replace double quotes with single quotes for each HREF/IMG code block given to you; just follow the way these are formatted.
$ads = array(
"<a href='http://www.dpbolvw.net/click-1685725-10376892' target='_top' ><img src='http://www.tqlkg.com/image-1685725-10376892' width='120' height='600' alt='The Tire Rack - Performance Specialists' border='0'></a>",
"<a href='http://www.kqzyfj.com/click-1685725-10356334' target='_top' ><img src='http://www.awltovhc.com/image-1685725-10356334' width='125' height='125' alt='' border='0'></a>",
"<a href='http://www.anrdoezrs.net/click-1685725-10278397' target='_top' ><img src='http://www.awltovhc.com/image-1685725-10278397' width='120' height='600' alt='Yahoo! Personals - Give Fate a Nudge!' border='0'></a>",
"<a href='http://www.dpbolvw.net/click-1685725-10313648' target='_top' ><img src='http://www.tqlkg.com/image-1685725-10313648' width='120' height='600' alt='' border='0'></a>",
"<a href='http://www.anrdoezrs.net/click-1685725-10384367' target='_top' ><img src='http://www.lduhtrp.net/image-1685725-10384367' width='125' height='600' alt='14 Months FREE Hosting at PowWeb!' border='0'></a>",
"<a href='http://www.jdoqocy.com/click-1685725-10292668' target='_top' ><img src='http://www.afcyhf.com/image-1685725-10292668' width='125' height='125' alt='Reduce Your Credit Card Payments by 50%' border='0'></a>",
"<a href='http://www.jdoqocy.com/click-1685725-5346684' target='_top' ><img src='http://www.afcyhf.com/image-1685725-5346684' width='120' height='240' alt='Find your Sould Mate' border='0'></a>",
"<a href='http://www.jdoqocy.com/click-1685725-10374173' target='_top' ><img src='http://www.ftjcfx.com/image-1685725-10374173' width='160' height='600' alt='' border='0'></a>",
"<a href='http://www.anrdoezrs.net/click-1685725-10363409' target='_top' ><img src='http://www.awltovhc.com/image-1685725-10363409' width='120' height='90' alt='JC Whitney Brand' border='0'></a>",
"<a href='http://www.jdoqocy.com/click-1685725-10378650' target='_top' ><img src='http://www.afcyhf.com/image-1685725-10378650' width='120' height='240' alt='Find Cars for Sale Locally at LiveDealAutos.com' border='0'></a>",
"<a href='http://www.jdoqocy.com/click-1685725-10382533' target='_top' ><img src='http://www.awltovhc.com/image-1685725-10382533' width='120' height='600' alt='GoDaddy $3.99 Domain Name Sale' border='0'></a>",
"<a href='http://www.anrdoezrs.net/click-1685725-10383588' target='_top' ><img src='http://www.afcyhf.com/image-1685725-10383588' width='125' height='125' alt='$6.95 Web Hosting' border='0'></a>",
"<a href='http://www.jdoqocy.com/click-1685725-10296928' target='_top' ><img src='http://www.tqlkg.com/image-1685725-10296928' width='120' height='90' alt='Click here for eBay Motors! ' border='0'></a>",
"<a href='http://www.dpbolvw.net/click-1685725-10314239' target='_top' ><img src='http://www.awltovhc.com/image-1685725-10314239' width='125' height='60' alt='Do Even More' border='0'></a>",
"<a href='http://www.jdoqocy.com/click-1685725-10382112' target='_top' ><img src='http://www.awltovhc.com/image-1685725-10382112' width='120' height='240' alt='PC-cillin' border='0'></a>"
);
$keys = array_rand($ads, 3);
// this is ad #1
echo $ads[$keys[0]] . "\n";
echo "<p>";
// ... ad #2
echo $ads[$keys[1]] . "\n";
echo "<p>";
// ad #3!
echo $ads[$keys[2]] . "\n";
// feel free to add more/remove some ads by copy/pasting the "echo $ads..." line over and over.
// * JUST make sure you change the # in the "$keys = array_rand..." line to reflect the # of ads you want to show.
?>
<!-- /'other' ads code -->
anyone know?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.