vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Creating Page Within Page? (https://vborg.vbsupport.ru/showthread.php?t=201015)

MarkFoster 01-07-2009 11:07 PM

Creating Page Within Page?
 
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

Quote:

Originally Posted by Bellardia (Post 1704613)
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
Quote:

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

PHP Code:

if ($_GET['do'] == 'Something')
{
   
//do something



MarkFoster 01-08-2009 12:47 AM

Quote:

Originally Posted by Bellardia (Post 1704638)
$_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

PHP Code:

if ($_GET['do'] == 'Something')
{
   
//do something



But if I do like this:
PHP Code:

if ($_GET['do'] == '?newsmain1')
{
[
B]   //do something[/B]


What will the command be to load a template and that template only, not the template that is on.com/name.php[S]?newsmain1[/S] ?

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

Quote:

Originally Posted by Bellardia (Post 1704687)
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

PHP Code:

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

Quote:

Originally Posted by Bellardia (Post 1704699)
PHP Code:

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:
PHP Code:

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

Quote:

Originally Posted by Bellardia (Post 1704713)
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/showthrea...lletin+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

Quote:

Originally Posted by Dismounted (Post 1704743)
Create your own vBulletin page, then you can use the above conditionals.

I know, I created my own page that way.

Now I added:
PHP Code:

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

Quote:

Originally Posted by MarkFoster (Post 1704802)
I know, I created my own page that way.

Now I added:
PHP Code:

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

Quote:

Originally Posted by Bellardia (Post 1704808)
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

Quote:

Originally Posted by Dismounted (Post 1704822)
Please post the entire file you are using.

Okay:
PHP Code:

<?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 Code:

<?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

Quote:

Originally Posted by Dismounted (Post 1704830)
PHP Code:

<?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:
PHP Code:

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 Code:

<?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

Quote:

Originally Posted by Dismounted (Post 1704879)
PHP Code:

<?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.


All times are GMT. The time now is 06:32 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.02238 seconds
  • Memory Usage 1,866KB
  • 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
  • (14)bbcode_php_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (23)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete