View Full Version : Help
vietkieu_cz
01-07-2006, 04:02 PM
Help me with Creating Custon Sub-Pages.
I've asked here but nobody answered me.(https://vborg.vbsupport.ru/showthread.php?goto=lastpost&t=98009)
I want to create a sub-custom page -
I read here but did not understand
Creating "Subpages"
If you want to create "subpages" within your custom page, simply wrap blocks of code with the following structure:
if ($_REQUEST['do'] == 'test')
{
// Block of code #1
}
if ($_REQUEST['do'] == 'test2')
{
// Block of code #2
}
Where do I add Php Code?
How I create subpages in AdminCP (Templates)?
Get the Link to Subpages? ...test.php?page=2 ???
harmor19
01-08-2006, 02:13 AM
let's say you named your script "test.php"
<?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', 'test');
// #################### 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
'test_mytesttemplate1',
'test_mytesttemplate2',
'test_mytesttemplate3',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
// #################### 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)
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = "main";
}
//test.php
if ($_REQUEST['do'] == "main")
{
$navbits[$parent] = 'Main Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('test_mytesttemplate1') . '");');
}
//test.php?do=test
if ($_REQUEST['do'] == "test")
{
$navbits[$parent] = 'Test Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('test_mytesttemplate2') . '");');
}
//test.php?do=test2
if ($_REQUEST['do'] == "test2")
{
$navbits[$parent] = 'Test Page 2';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('test_mytesttemplate3') . '");');
}
?>
vietkieu_cz
01-25-2006, 01:22 PM
Thanks harmor19
Now I want to add custom template
e.x.:
in my template test_mytesttemplate1, there I add $customtemp
then i add a new temp. called customtemp
now what I have to add in my test.php script?
harmor19
01-25-2006, 02:30 PM
Use
eval('$customtemp = "' . fetch_template('customtemp') . '";');
Place this in the same subpage where the template where you would like the html of "customtemp" to be.
In this case you want to place the new template function in this section.
if ($_REQUEST['do'] == "main")
{
$navbits[$parent] = 'Main Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('test_mytesttemplate1') . '");');
}
It doesn't matter where you put it but I would suggest above the existing fetch_template function.
if ($_REQUEST['do'] == "main")
{
$navbits[$parent] = 'Main Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('$customtemp = "' . fetch_template('customtemp') . '";');
// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('test_mytesttemplate1') . '");');
}
I'll explain how a fetch_template function with a variable works.
[COLOR=Red]eval('$customtemp = "' . fetch_template('customtemp') . '";');
The "$customtemp" variable is what you put in another template file.
So in the "test_mytesttemplate1" template you should have the variable "$customtemp".
The text in side the "fetch_template" function (which is "customtemp") is the template it's getting the html from.
vietkieu_cz
01-30-2006, 10:55 AM
thank you harmor again :)
I need a code for my custom page, which connects to phpmyadmin and gets the term of a post (e.x. id of post 1)
can you help me?
- sorry for my bad english
thanks
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.