The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Creating Custom Pages
Hi,
Where can i get tutorials for "Creating Custom Pages that query the database"? I have read How to create your own vBulletin-powered page! (uses vB templates) at https://vborg.vbsupport.ru/showthrea...=62164&page=32 I have also read about the database classes. As i understand now, i have to do the coding part in the php file and create a template to display the data. How do i pass data obtained from the database to the template. If there is any guide/tutorial for the same, please give me the link. If there isnt please give me some pointers Thanks in advance |
#2
|
|||
|
|||
So, Noone replied!! I guess i have asked a very broad question..
Let me start with a narrower one Suppose i make a file test.php and retrive some values from a database. Now, i want to display those values. How exactly do i go about doing so? I mean the values will be displayed in the templates and the retrieve done in the php, so how does one go about passing values to the template. I hope i explained my query properly. Thanks in advance ~M |
#3
|
|||
|
|||
Here is a section of code from one of my pages that should help you out. I'm not sure I can explain it all, but I know it works.
Code:
if ($_REQUEST['do'] == 'Calculate with Own Data') { $eng=$_POST["engine"]; $overbore=$_POST["overbore"]; $conn=mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $result = mysql_query("SELECT * FROM cr_calc_data WHERE engine = $eng"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($result); mysql_close($conn); $engine=$row[8]; $bore = $row[1]+$overbore; $navbits = array(); $navbits[$parent] = 'CR Calculator - Default Values'; $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('CRCALC2') . '");'); } |
#4
|
|||
|
|||
Thanks tht helped.
I am facing a problem now with scripts placed outside the vbulletin directory See http://www.genportal.org/team/team_builder.php The forum is located at genportal.org/forum/ The images and the links do not work because they dont get the right path... Here is the code i have used. What have i done wrong Code:
<?php // ######################## SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // ##################### DEFINE IMPORTANT CONSTANTS ####################### // change the line below to the actual filename without ".php" extention. // the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation. define('THIS_SCRIPT', 'team_builder'); // #################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array(); // get special data templates from the datastore $specialtemplates = array(); // pre-cache templates used by all actions $globaltemplates = array( // change the lines below to the list of actual templates used in the script 'team_builder', 'team_builder2', ); // pre-cache templates used by specific actions $actiontemplates = array(); // ########################## REQUIRE BACK-END ############################ chdir('../forum'); require_once('./global.php'); if (!$vbulletin->userinfo['userid']) { print_no_permission(); } // #################### HARD CODE JAVASCRIPT PATHS ######################## $headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude); // ######################################################################## // ######################### START MAIN SCRIPT ############################ // ######################################################################## $navbits = array(); // change the line below to contain whatever you want to show in the navbar (title of your custom page) $navbits[$parent] = 'Team Builder'; $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); $hello = "Hello World"; // change the line below to contain the name of the actual main output template used in your script eval('print_output("' . fetch_template('team_builder') . '");'); ?> |
#5
|
|||
|
|||
Change your links in your header, footer and navbar templates to full links.
Change your image paths to full URL's. This happens with anything that is not in the same directory. |
#6
|
|||
|
|||
Wht about CSS?
The pages dont get the CSS as well Where is $style[css] defined? |
#7
|
|||
|
|||
Try using the CSS in the db instead of the filesystem
|
#8
|
|||
|
|||
How does one do that? Please explain
I havent changed anything. Is the default CSS from the file or from the database |
#9
|
|||
|
|||
It seems to be working ok here with the default style. Is it the default style or another one that you are having problems with?
BTW, your CSS is stored in the db already. |
#10
|
|||
|
|||
Thanks
How do i get IP and username of the person on my page?? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|