Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2007, 06:41 AM
larryd larryd is offline
 
Join Date: Nov 2001
Location: Newark, DE
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I run a PHP script in my templates? (VB 3.03)

I have written my own code to randomly display a banner that is PHP/mySQL based. What I am trying to figure out is how to get the code which works great when I call it myself to work with Vbulletin.

The code is

PHP Code:

<?

include("include/dbconnect.php");

$result = mysql_query("SELECT * FROM $table where active = 'Y' ORDER BY RAND() LIMIT 0,1",$db);

$row = mysql_fetch_array($result);
$did = $row["did"];
$image_url = $row["image_url"];
$url = $row["url"];
$alt_text = $row["alt_text"];
$target = $row["target"];
$width = $row["width"];
$height = $row["height"];
$active = $row["active"];
$richtext = $row["richtext"];
$code = $row["code"];

if ($richtext == 'Y') { $banner = "$code"; } ELSE { $banner = "<a href='$url' target='$target'><img src='$image_url' border='0' alt='$alt_text' width='$width' height='$height'></a>"; }

echo "$banner";

?>
I tried calling this in my forum header template by saying

<script src="http://www.newcelica.org/banners/display.php"></script>

But it does not display anything. Any help is truly appreciated as I'm stumped on this one.
Reply With Quote
  #2  
Old 01-19-2007, 07:09 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<script> tags are used for client-side scripting. PHP is server-side. Have you tried editing the core files directly?
Reply With Quote
  #3  
Old 01-19-2007, 07:42 AM
larryd larryd is offline
 
Join Date: Nov 2001
Location: Newark, DE
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you mean edit index.php rather then the templates. I suppose thats an option but figuring out how to get the placement exactly where you want it with out using the templates is a pita.
Reply With Quote
  #4  
Old 01-19-2007, 08:37 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just copy the script into the correct php file and ommit the "echo". And then just put $banner where you want it in the templates.
Reply With Quote
  #5  
Old 01-31-2007, 04:52 PM
larryd larryd is offline
 
Join Date: Nov 2001
Location: Newark, DE
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried that and it did not work; It doesn't display anything.

I added the following to the index.php file
require_once('/pathto/display_ar.php');

And in the display_ar.php file I simply set the variable $banner and I tried calling it in my header template and it did nothing.
Reply With Quote
  #6  
Old 01-31-2007, 05:06 PM
Digitalus Digitalus is offline
 
Join Date: Aug 2006
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why dont you make a plugin?

Hook Location global_start

ob_start();
include('/pathto/display_ar.php'');
$banner = ob_get_contents();
ob_end_clean();

and put $banner in your template
Reply With Quote
  #7  
Old 01-31-2007, 05:23 PM
larryd larryd is offline
 
Join Date: Nov 2001
Location: Newark, DE
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

tried that too.. I put it in the PHP Include Start Template. And it did nothing either.
Reply With Quote
  #8  
Old 02-02-2007, 05:28 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Errr, vBulletin 3.0.3 has not got a plugin system.
Reply With Quote
  #9  
Old 02-02-2007, 12:01 PM
alexhirurg alexhirurg is offline
 
Join Date: Jan 2007
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

also don't forget to set your variable global in plugin - if you will make plugin!

global $banner;
$banner = .....

otherwise you will not see your variable in some templates.
Reply With Quote
  #10  
Old 02-03-2007, 01:23 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by alexhirurg View Post
also don't forget to set your variable global in plugin - if you will make plugin!

global $banner;
$banner = .....

otherwise you will not see your variable in some templates.
Do you not understand vBulletin 3.0.3 doesn't have a plugin system?
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:29 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04350 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete