vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   How To New Pages in vb style (https://vborg.vbsupport.ru/showthread.php?t=88565)

Bilderback 03-01-2008 05:03 PM

Quote:

Originally Posted by Arcanum (Post 715111)
Okay but what about coding a .php file to handle more than 1 template?

In order to use a single php file for multiple templates, you would use url variations using $_GET.
If your main page was information.php you would have to write multiple request methods such as:
information.php?do=main
information.php?do=contact
information.php?do=about

You would create your templates and put them all into the $globaltemplates array() like
$globaltemplates = array(
'main',
'contact',
'about'
);
When working with multiple templates, I do advise to use some prefix such as info_ or something.
Then you setup your php file to handle the requests.
PHP Code:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
 
error_reporting(E_ALL & ~E_NOTICE);
 
// #################### DEFINE IMPORTANT CONSTANTS #######################
 
define('NO_REGISTER_GLOBALS'1);
 
define('THIS_SCRIPT''yourscript');
 
// ################### 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(
'main',
'contact',
'about'
);
 
// pre-cache templates used by specific actions
 
$actiontemplates = array();
 
// ######################### REQUIRE BACK-END ############################
 
require_once('./global.php');

// Begin your templates
// Main template and code
if ($_REQUEST['do'] == 'main')
{
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'print_output("' fetch_template('main') . '");');
}
// Contact template and code
if ($_REQUEST['do'] == 'contact')
{
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'print_output("' fetch_template('contact') . '");');
}
// About template and code
if ($_REQUEST['do'] == 'about')
{
    eval(
'$navbar = "' fetch_template('navbar') . '";');
    eval(
'print_output("' fetch_template('about') . '");');
}
?>

Its a bit complex and hard for me to explain in a spur of the moment forum post,
but basically, you have to handle the code for your different url requests, then
write the different eval() to fetch the templates within those requests.
I suggest looking into the code of a product that uses multiple urls to get a better understanding.

******************************

Quote:

Originally Posted by Never2Day (Post 1453710)
I have no idea how to do this sorry I have managed to do the first part but the second code i have no idea what to do with where to put it or what i should do cause when i did put it onto a blank page i got errors.

Your created template may contain anything you wish, even if its a simple <b>Welcome</b>
But, if you want it to be contained within your forum layout, there are several variables you must call such as $headinclude,$header,$navbar and $footer
This places your content within the vbulletin page.
Simply by pasting the code provided into a new template should work for you.

As far as the PHP file, there are really only two areas you need to edit.
These areas MUST conform to the template name you just created.
Code:

// pre-cache templates used by all actions
 $globaltemplates = array(
 'TEMPLATENAME'
 );

and
Code:

eval('print_output("' . fetch_template('TEMPLATENAME') . '");');
Lets say you create a template named aboutme
You would edit the supplied php code in this thread to:
Code:

$globaltemplates = array(
 'aboutme'
 );

and
Code:

eval('print_output("' . fetch_template('aboutme') . '");');
within the php file.
Save the file as aboutme.php and upload to your forum root so when people
visit www.yoursite.com/forum/aboutme.php
it will display the contents of the template you created.

If you need assistance with a simple page, contact me.

I'd like to add that sometimes the forumjump menu does not work on pages
in which case you need to add
PHP Code:

construct_forum_jump(); 

above eval('$navbar = "' . fetch_template('navbar') . '";');

Also, if you would like to have the name appear in the navbar when viewing the page,use
PHP Code:

$navbits construct_navbits(array('' => 'YOUR PAGE NAME HERE')); 

above eval('$navbar = "' . fetch_template('navbar') . '";');


All times are GMT. The time now is 05:59 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01571 seconds
  • Memory Usage 1,744KB
  • 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
  • (4)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_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
  • (1)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