Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2006, 09:34 AM
aragorn_reborn aragorn_reborn is offline
 
Join Date: Nov 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 12-02-2006, 10:32 AM
aragorn_reborn aragorn_reborn is offline
 
Join Date: Nov 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #3  
Old 12-02-2006, 04:01 PM
wottech wottech is offline
 
Join Date: May 2006
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 12-04-2006, 03:41 PM
aragorn_reborn aragorn_reborn is offline
 
Join Date: Nov 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

?>
Reply With Quote
  #5  
Old 12-04-2006, 04:05 PM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 12-05-2006, 06:25 PM
aragorn_reborn aragorn_reborn is offline
 
Join Date: Nov 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wht about CSS?

The pages dont get the CSS as well

Where is $style[css] defined?
Reply With Quote
  #7  
Old 12-05-2006, 06:40 PM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using the CSS in the db instead of the filesystem
Reply With Quote
  #8  
Old 12-05-2006, 06:47 PM
aragorn_reborn aragorn_reborn is offline
 
Join Date: Nov 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How does one do that? Please explain

I havent changed anything. Is the default CSS from the file or from the database
Reply With Quote
  #9  
Old 12-05-2006, 06:50 PM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 12-05-2006, 08:46 PM
aragorn_reborn aragorn_reborn is offline
 
Join Date: Nov 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks

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


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 11:50 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.04474 seconds
  • Memory Usage 2,257KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_code
  • (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_postinfo_query
  • fetch_postinfo
  • 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