The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
using/exporting php code in templates
Hey guys. The forum I help run has requested a public ban list. I've already got a php script looking at the userban table in vB and outputting the data in a table(don't know css ). Thing is, it looks bland. I'd like to make it look like it's integrated with our forums. I've followed How to create your own vBulletin-powered page! (uses vB templates) and have a custom page setup. Thing is, I'm not sure how to get the data in there. Am I missing something obvious? I don't think you can use php in templates and not sure if a plugin would do this properly(or at all)
Thanks in advance. |
#2
|
||||
|
||||
You put your PHP into your file and assign the output to a variable. Then use that variable to display the data in the template.
|
#3
|
||||
|
||||
Ok, so how do I do that? I've got the template set up, all the code is being assigned to a variable...but when I type that variable into the template, nothing happens. I get the feeling I'm missing something trival here...
Here's a portion of the template($output is the var assigned to be the output): Code:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat">Title</td> </tr> <tr> $output </tr> </table> |
#4
|
||||
|
||||
Have you considered this mod: VBAREA - Banned Users List 1.1
(Not that I want to dissuade you from learning how to write a mod yourself.) |
#5
|
||||
|
||||
It looks nice(and will probably end up using it instead) but I would still like the answer to my problem.
Thank you for the link, though |
#6
|
||||
|
||||
Why don't you post your php script.
You are evaling the template, right? |
#7
|
||||
|
||||
PHP Code:
Code:
$stylevar[htmldoctype] <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> <title>$vboptions[bbtitle]</title> $headinclude </head> <body> $header $navbar <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat">Title</td> </tr> <tr> $output </tr> </table> $footer </body> </html> |
#8
|
||||
|
||||
You need to eval your template *after* you have defined $output. So, move this line to the bottom of your php page (or at least to after you have defined $output):
eval('print_output("' . fetch_template('publicbanlist') . '"); |
#9
|
||||
|
||||
|
#10
|
||||
|
||||
Are you using the same database that vbulletin uses? If so, you really don't need to go through and define all the database stuff again. It should be available to you after you call global.php. So, try rewriting some of the stuff just as if it were vb stuff, ie. "$db->query_read" instead of "mysql_query" and "while ($row = $db->fetch_array($r))" instead of "while ($row = mysql_fetch_array($r, MYSQL_BOTH))". In the while loop, you would then use "$row[username]" instead of "retUsername($row[0])".
(Disclaimer: I write code by trial and error so often, so I hope I'm not steering you wrong here.) |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|