vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   php code in templates (https://vborg.vbsupport.ru/showthread.php?t=155351)

webgod 08-15-2007 09:32 PM

php code in templates
 
I'm a programmer by profession, but I am still trying to get the hang of Vbulletin.

here is what I am trying to do:

I'd like to place a snippet of code in the footer template that creates an array which israndom sorted then spits it out the resultants...

basically I'm randomize the display order of ~ 50 images.


The code works perfectly in a standalone php page...
however when I insert it into the footer template, it obviously does not.


so my question is, what is the easiest way of achieving my result?


here's a snippet of the php code structure:
PHP Code:

$randimgs = array (
"<img src='1.jpg'>",
"<img src='2.jpg'>",
"<img src='3.jpg'>",
"<img src='4.jpg'>");

srand((float)microtime() * 1000000);
shuffle($randimgs);
foreach (
$randimgs as $randimg) {
    echo 
"$randimg";



Wayne Luke 08-15-2007 09:42 PM

The easiest way? Creating a plugin. You can't put PHP code into vBulletin's templates for security purposes. (((Though with the new plugin system this is kind of oxymoronic))).

Put your code in a global_start plugin and assign the output to a variable. Then put that variable in your footer template.

webgod 08-15-2007 09:45 PM

Quote:

Originally Posted by Wayne Luke (Post 1318489)
The easiest way? Creating a plugin. You can't put PHP code into vBulletin's templates for security purposes. (((Though with the new plugin system this is kind of oxymoronic))).

Put your code in a global_start plugin and assign the output to a variable. Then put that variable in your footer template.

after I posted I had the same idea...

except I put the php code in the global.php page


and instead of echo(ing) the result I'll load it into a variable and up the variable in the footer template

my method with global.php did not work.

but your plugin method sure did.

thanks a million :up:


All times are GMT. The time now is 01:44 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.01510 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete