Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2005, 08:51 PM
webghey webghey is offline
 
Join Date: May 2005
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default easy one: how to parse PHP code on page gen?

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:

Code:
<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.

Code:
<?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!! =)
Reply With Quote
  #2  
Old 06-14-2005, 09:07 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

add: require_once('./random.php'); to you PHPINCLUDE_Start template.
Reply With Quote
  #3  
Old 06-14-2005, 09:23 PM
webghey webghey is offline
 
Join Date: May 2005
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #4  
Old 06-14-2005, 09:25 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 06-14-2005, 09:37 PM
webghey webghey is offline
 
Join Date: May 2005
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, this is it


Code:
<!-- 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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03938 seconds
  • Memory Usage 2,213KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete