View Full Version : Simple Page.... no working!!!
rob30UK
01-21-2006, 11:08 PM
Hi,
I'm using some code to pull out a custom template to display in a page with the vBulletin header (no navbar)....
I'm trying to pass in themplate name with a querystring...
Here is the code
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// pre-cache templates used by all actions
$reqpage = $_REQUEST['reqpage'];
$globaltemplates = array(
$reqpage,
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// Static Pages
eval('print_output("' . fetch_template($reqpage) . '");');
?>
For some reason I cant understand, it's not working. My code is prolly wrong anyway, I get this error:-
Warning: Division by zero in /includes/functions.php(4314) : eval()'d code on line 10
I know it's failing on the last line, and I've tried others like:-
eval('print_output("' . fetch_template(' + $reqpage + ') . '");');
Hopefully someone can see what I'm trying to achieve.... but I just cant get it to work.
What am I doing wrong?
Thanks.
Daniel
01-21-2006, 11:13 PM
Have you looked at this tutorial?
https://vborg.vbsupport.ru/showthread.php?t=98009
But from looking over the tutorial I posted above... try this.
<?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', 'CHANGE_THIS_TO_YOUR_FILE_NAME');
// #################### 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
'reqpage',
);
// 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)
$navbits[$parent] = 'Test Page';
// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('reqpage') . '");');
?>
I'm not a coder or anything, but I tried my best. Best of luck :p
Guest190829
01-21-2006, 11:17 PM
Some of your code is wrong.
I don't know what this is:
$reqpage = $_REQUEST['reqpage'];
$globaltemplates = array(
$reqpage,
);
That part should be deleted to this:
$globaltemplates = array(
'template_name'
);
(Change template_name with the actualy template name of the template your using)
Then the eval should be:
eval('print_output("' . fetch_template('template_name') . '");');
peterska2
01-21-2006, 11:19 PM
try eval('print_output("' . fetch_template('reqpage') . '");');and$globaltemplates = array(
reqpage,
); in the relevant places
[edit]
Damn, everyone pounced at once!
Guest190829
01-21-2006, 11:20 PM
Ah why is my font green. :(
peterska2
01-21-2006, 11:20 PM
Ah why is my font green. :(
It's not, it's red ;) :p
Adrian Schneider
01-22-2006, 12:08 AM
Some of your code is wrong.
I don't know what this is:
$reqpage = $_REQUEST['reqpage'];
$globaltemplates = array(
$reqpage,
);
That part should be deleted to this:
$globaltemplates = array(
'template_name'
);
(Change template_name with the actualy template name of the template your using)
Then the eval should be:
eval('print_output("' . fetch_template('template_name') . '");');
He's trying to pull the template in the query string...
Post your actual template here.
rob30UK
01-22-2006, 07:03 AM
Hi and thanks everyone above for trying to help.
This php page is a one-size fits all page for static pages.
You pass it the name of the template (via querystring) and the script should grab the template and display it!
Basically, it's called like this:-
pagecontent.php?reqpage=Static_SEO
In this case, Static_SEO is the template name.
SirAdrian, all the templates I've tested this with are certified error free... non of the templates are a problem.... it's this code.
Can I ask everyone to refer back to my original code above and just note that $reqpage is a string variable pulled in from the querystring.
I'm sure the last line is where the error is (maybe?) because the value of $reqpage definitly comes through.
Any ideas?
Adrian Schneider
01-22-2006, 07:33 AM
Your php code works fine for me.
Why not humor me and post it (my guess is line 10 of your template;))? Also, which version of vBulletin is this?
rob30UK
01-22-2006, 08:07 AM
Here is the page I'm requesting with that EXACT php code:-
http://www.webforumz.com/pagecontent.php?reqpage=STATICSEO
Here is the template which is there as a test:-
Product: vBulletin
Style: Default Style
Title: STATICSEO
Template:$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>test</title>
$headinclude
</head>
<body>
$header
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">Title</td>
</tr>
<tr>
<td class="alt1">Text</td>
</tr>
</table>
$footer
</body>
</html>
I'm using vB 3.5.
Here is the php again just for my sanity:-
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// pre-cache templates used by all actions
$reqpage = $_GET['reqpage'];
$globaltemplates = array(
$reqpage,
);
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
// Static Pages
eval('print_output("' . fetch_template($reqpage) . '");');
?>
Weird, huh
I can't understand why this is not working. :(
Ok.... this is really weird..
If I change the last line so it doesnt use a variable, eg:-
eval('print_output("' . fetch_template('STATICSEO') . '");');it works fine...
Yet if I use it like this:-
eval('print_output("' . fetch_template($reqpage) . '");');
It does work...even if I user this in place of the get: $reqpage="STATICSEO";
The last line is obviously screwing things up a little.
Any ideas?
Princeton
01-22-2006, 12:34 PM
I use something similar.
I recommend cleaning the $_GET value...
below the require_once('./global.php'); add $vbulletin->input->clean_gpc('r', 'reqpage', TYPE_NOHTML);
You should also...
clean the $_GET value before adding it to $globaltemplates array (just in case)
check if template does exist ... if it doesn't exist redirect to front page or error page (eg. someone could have copied the url wrong)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.