View Full Version : Creating Page Within Page?
MarkFoster
01-07-2009, 11:07 PM
How do I create a page within a page for example: www.example.com/example.php?do=news
Or something like: www.example.com/example.php?action=news
I really need this soon so any help appreciated.
Bellardia
01-07-2009, 11:15 PM
Use php $_GET['do'] and $_GET['action'] to get the query string.
Use an if condition...if ($_GET['do'] == 'something') { DO THIS } else { DO THIS } etc
Of course, this would be done in php.
MarkFoster
01-07-2009, 11:28 PM
Use php $_GET['do'] and $_GET['action'] to get the query string.
Use an if condition...if ($_GET['do'] == 'something') { DO THIS } else { DO THIS } etc
Of course, this would be done in php.
Could you make it in a quote what I should add?
I tried this many times without anything at all working
if ($_REQUEST['do'] == 'xxx')
{
eval('print_output("' . fetch_template('TEMPLATE_XXX') . '");');
}
Bellardia
01-07-2009, 11:53 PM
$_REQUEST is a very different function than $_GET.
Not sure what exactly you want to do with the code, so I won't tell you want to evaluate inside or anything...but to do something based on the query string use the code
if ($_GET['do'] == 'Something')
{
//do something
}
MarkFoster
01-08-2009, 12:47 AM
$_REQUEST is a very different function than $_GET.
Not sure what exactly you want to do with the code, so I won't tell you want to evaluate inside or anything...but to do something based on the query string use the code
if ($_GET['do'] == 'Something')
{
//do something
}
But if I do like this:
if ($_GET['do'] == '?newsmain1')
{
//do something
}
What will the command be to load a template and that template only, not the template that is on.com/name.php?newsmain1 ?
Bellardia
01-08-2009, 01:05 AM
You leave the '?' out of the $_GET command.
I advise you ask someone to do this for you, as you don't know PHP. You cant use bb code in php, nor html (directly).
Although a relatively simple task, would take awhile to explain from scratch, especially when unaware of your intentions. I would advise checking out some php tutorials.
Lynne
01-08-2009, 01:06 AM
Don't put the question mark in the if statement ('newsmain1' only) Try your if statement with that correction.
MarkFoster
01-08-2009, 01:13 AM
You leave the '?' out of the $_GET command.
I advise you ask someone to do this for you, as you don't know PHP. You cant use bb code in php, nor html (directly).
Although a relatively simple task, would take awhile to explain from scratch, especially when unaware of your intentions. I would advise checking out some php tutorials.
All I really need is one PHP command which will let me add a page within a PHP file with my own template.
And that's about it so I'm pretty sure somebody has a code for that.
Bellardia
01-08-2009, 01:20 AM
if ($_GET['do'] == 'Something')
{
include('PAGENAME.HTML');
}
Change 'something' to what will be after do=, ie, if your page is www.mypage.com?do=run, then change it to 'something'. Change $_GET['do'] to what is before the equal sign...you could make it www.mypage.com?returnpage=first, then you would used $_GET['returnpage']. Use the include to fetch a html/php page from the same directory, or link it appropriately.
Or fetch a template instead.
MarkFoster
01-08-2009, 01:37 AM
if ($_GET['do'] == 'Something')
{
include('PAGENAME.HTML');
}
Change 'something' to what will be after do=, ie, if your page is www.mypage.com?do=run, then change it to 'something'. Change $_GET['do'] to what is before the equal sign...you could make it www.mypage.com?returnpage=first, then you would used $_GET['returnpage']. Use the include to fetch a html/php page from the same directory, or link it appropriately.
Or fetch a template instead.
I would rather fetch a template but this code wont work:
if ($_GET['do'] == 'news1')
{
eval('print_output("' . fetch_template('newsmain1') . '");');
}
Could you give me a exact fetch template line?
Bellardia
01-08-2009, 01:42 AM
Depends what page it is running on and where.
MarkFoster
01-08-2009, 01:51 AM
Depends what page it is running on and where.
Page I coded called news.php.
It's supposed to be another page like example of something that isn't two pages in one but still example: forum 1 with a thread as another page.
I want there to be another page within a PHP file so I wont have to create a PHP file for every page I want.
Bellardia
01-08-2009, 02:07 AM
What you're doing isn't really a 'page in a page', it's changing the output of a page based on an if condition. A page in a page would typically be a frame.
In any case, try this tutorial https://vborg.vbsupport.ru/showthread.php?t=62164&highlight=vbulletin+powered combined with the 'if' condition I showed you above.
Dismounted
01-08-2009, 02:08 AM
<a href="https://vborg.vbsupport.ru/showthread.php?t=62164" target="_blank">Create your own vBulletin page</a>, then you can use the above conditionals.
MarkFoster
01-08-2009, 03:42 AM
Create your own vBulletin page (https://vborg.vbsupport.ru/showthread.php?t=62164), then you can use the above conditionals.
I know, I created my own page that way.
Now I added:
if ($_GET['do'] == 'do=run')
{
eval('print_output("' . fetch_template('TEST') . '");');
}
Still nothing working.
Could somebody give me a code instead of letting a non experienced person mess around?
Bellardia
01-08-2009, 04:12 AM
I know, I created my own page that way.
Now I added:
if ($_GET['do'] == 'do=run')
{
eval('print_output("' . fetch_template('TEST') . '");');
}
Still nothing working.
Could somebody give me a code instead of letting a non experienced person mess around?
I've told you several times now how to use the $_GET function, and every time you post you change it around. Re-read my above posts please.
MarkFoster
01-08-2009, 04:37 AM
I've told you several times now how to use the $_GET function, and every time you post you change it around. Re-read my above posts please.
I've tried getting it around now over and over again.
Sorry I'm just not good at this.
Please just give me a code instead.
Dismounted
01-08-2009, 05:13 AM
Please post the entire file you are using.
MarkFoster
01-08-2009, 05:15 AM
Please post the entire file you are using.
Okay:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'test'); // change this depending on your filename
// ################### 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(
'TEST',
);
// pre-cache templates used by specific actions
$actiontemplates = array(
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = array();
$navbits[$parent] = 'Test Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('news') . '");');
if ($_GET['do'] == 'do=run')
{
eval('print_output("' . fetch_template('TEST') . '");');
}
?>
Dismounted
01-08-2009, 05:19 AM
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
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(
'TEST',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = array();
$navbits[$parent] = 'Test Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
if ($_GET['do'] == 'run')
{
eval('print_output("' . fetch_template('TEST') . '");');
}
?>
MarkFoster
01-08-2009, 05:38 AM
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
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(
'TEST',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = array();
$navbits[$parent] = 'Test Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
if ($_GET['do'] == 'run')
{
eval('print_output("' . fetch_template('TEST') . '");');
}
?>
That worked out well but I got a problem.
I still want the:
eval('print_output("' . fetch_template('news') . '");');
For the "news.php" but if I add it then the "?do=run" will be the exact same page as the "news.php" is there any way I could have them both?
Dismounted
01-08-2009, 07:17 AM
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
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(
'news'
);
// pre-cache templates used by specific actions
$actiontemplates = array(
'run' => array(
'TEST'
)
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = array();
$navbits[$parent] = 'Test Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
if ($_GET['do'] == 'run')
{
eval('print_output("' . fetch_template('TEST') . '");');
}
else
{
eval('print_output("' . fetch_template('news') . '");');
}
?>
MarkFoster
01-08-2009, 04:25 PM
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
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(
'news'
);
// pre-cache templates used by specific actions
$actiontemplates = array(
'run' => array(
'TEST'
)
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = array();
$navbits[$parent] = 'Test Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
if ($_GET['do'] == 'run')
{
eval('print_output("' . fetch_template('TEST') . '");');
}
else
{
eval('print_output("' . fetch_template('news') . '");');
}
?>
It works perfect!
Thank you.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.