vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Creating Custom Pages (https://vborg.vbsupport.ru/showthread.php?t=132937)

aragorn_reborn 12-01-2006 09:34 AM

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

aragorn_reborn 12-02-2006 10:32 AM

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

wottech 12-02-2006 04:01 PM

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') . '");');       
}

The parts to look at are the POST command and then the EVAL command at the very end where it calls the template. I'll try to help you out where I can, but I'm only a novice coder. It took many tries before I got it all to work correctly.

aragorn_reborn 12-04-2006 03:41 PM

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') . '");');

?>


peterska2 12-04-2006 04:05 PM

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.

aragorn_reborn 12-05-2006 06:25 PM

Wht about CSS?

The pages dont get the CSS as well

Where is $style[css] defined?

peterska2 12-05-2006 06:40 PM

Try using the CSS in the db instead of the filesystem

aragorn_reborn 12-05-2006 06:47 PM

How does one do that? Please explain

I havent changed anything. Is the default CSS from the file or from the database

peterska2 12-05-2006 06:50 PM

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.

aragorn_reborn 12-05-2006 08:46 PM

Thanks

How do i get IP and username of the person on my page??


All times are GMT. The time now is 12:52 AM.

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.03080 seconds
  • Memory Usage 1,740KB
  • 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
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete