View Full Version : Custom page Script...
MarkFoster
11-14-2009, 11:53 PM
From this mod: https://vborg.vbsupport.ru/showthread.php?t=62164
What wuld this script be if I would be to use vB 4.0?
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header
$navbar
<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 have loads of custom pages and I really need the proper script to change them all.
ForumsMods
11-15-2009, 01:16 AM
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'test'); // change this depending on your filename
define('CSRF_PROTECTION', true);
// ################### 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 = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', 'Test Page');
print_output($templater->render());
?>{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>
<h2 class="blockhead">Title</h2>
<div class="blockbody">
<div class="blockrow">
Text
</div>
</div>
{vb:raw footer}
</body>
</html>
TheLastSuperman
11-15-2009, 01:18 AM
<?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 = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', 'Test Page');
print_output($templater->render());
?>
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>
<h2 class="blockhead">Title</h2>
<div class="blockbody">
<div class="blockrow">
Text
</div>
</div>
{vb:raw footer}
</body>
</html>
Right when I'm about to post LOL but good job!
HMBeaty
11-15-2009, 01:24 AM
Actually, to make a quick correction (if I remember correctly)...
This
error_reporting(E_ALL & ~E_NOTICE);
Should be
error_reporting(E_ALL & ~E_NOTICE & ~8192);
Dismounted
11-15-2009, 02:25 AM
Actually, to make a quick correction (if I remember correctly)...
No need to suppress E_DEPRECATED warnings now, as they should be fixed.
HMBeaty
11-15-2009, 02:30 AM
No need to suppress E_DEPRECATED warnings now, as they should be fixed.
Ok, sounds good. :) Thank you Dismounted
vB Style is god vBulletinized. :)
ragtek
11-15-2009, 07:41 AM
<?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 = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', 'Test Page');
print_output($templater->render());
?>
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>
<h2 class="blockhead">Title</h2>
<div class="blockbody">
<div class="blockrow">
Text
</div>
</div>
{vb:raw footer}
</body>
</html>
1. forgett define('NO_REGISTER_GLOBALS', 1);
2. include the csrf protection
We shouldn't start posting the outdated stuff;)
winstone
11-15-2009, 07:50 AM
what does following function do?
$templater->register_page_templates();
can we include other templates inside it? e.g. $templater->register_page_templates('top_bit', 'side_bit', 'etc');
Shadab
11-15-2009, 09:28 AM
what does following function do?
$templater->register_page_templates(); It makes the header, footer and headinclude templates available to the template being evaluated.
can we include other templates inside it? e.g. $templater->register_page_templates('top_bit', 'side_bit', 'etc');No. But you can do that via the register() method.
For example: [untested]
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('my_sidebar_1', vB_Template::create('sidebar_1')->render());
print_output($templater->render());
This would make the sidebar_1 template accessible via {vb:raw my_sidebar_1}
in your main TEST template.
ForumsMods
11-15-2009, 10:33 AM
1. forgett define('NO_REGISTER_GLOBALS', 1);
2. include the csrf protection
We shouldn't start posting the outdated stuff;)
1. Yes, I forgot to remove NO_REGISTER_GLOBALS.
Anyway, vBulletin reverse the effects of register_globals. It automatically unsets the globals.
if (@ini_get('register_globals') OR !@ini_get('gpc_order'))
{
foreach ($this->superglobal_lookup AS $arrayname)
{
$registry->superglobal_size["$arrayname"] = sizeof($GLOBALS["$arrayname"]);
foreach (array_keys($GLOBALS["$arrayname"]) AS $varname)
{
// make sure we dont unset any global arrays like _SERVER
if (!in_array($varname, $this->superglobal_lookup))
{
unset($GLOBALS["$varname"]);
}
}
}
}
2. Also I forgot it. I only copy and paste header and modifiy the body of the PHP.
I am going to update the script, and will create a tutorial with more things.
winstone
11-15-2009, 10:56 AM
Thanks a lot Shadab, it works the way you coded
however there is one little problem, if I register a variable in the code which is used in 'sidebar_1' template, I can't get it to show in the output using {vb:raw VariableInMySideBar} method
this is the code:
##The variable to be used in 'my_sidebar_1' template
$ExVariable= 'SomeAutoGeneratedContent';
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('my_sidebar_1', vB_Template::create('sidebar_1')->render());
##Register the variable
$templater->register('VariableInMySideBar', $ExVariable);
print_output($templater->render());
in the template 'TEST',
{vb:raw my_sidebar_1}
works fine
in 'sidebar_1' template:
{vb:raw VariableInMySideBar} doesn't work
and surprisingly
{$ExVariable} works fine, but I guess I shouldn't use it like that
cellarius
11-15-2009, 10:59 AM
1. forgett define('NO_REGISTER_GLOBALS', 1);
2. include the csrf protection
We shouldn't start posting the outdated stuff;)
I totally agree, and that's why you really should add
define('CSRF_PROTECTION', true);
after
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'test');
Thinking of it - I havn't seen NO_REGISTER_GLOBALS set in vB's core scripts since what, 3.0? I just checked and it vanished with 3.5, and in 4.0 there is no single reference to NO_REGISTER_GLOBALS that I can trace. Could it be that in fact this constant has been outdated for years but still makes it's way into modification codes because it was once needed years ago?
Paul M
11-15-2009, 11:51 AM
Actually, to make a quick correction (if I remember correctly)...
This
error_reporting(E_ALL & ~E_NOTICE);
Should be
error_reporting(E_ALL & ~E_NOTICE & ~8192);
No need to suppress E_DEPRECATED warnings now, as they should be fixed.
And even if you do, it should be -E_DEPRECATED , not -8192 ;)
Shadab
11-15-2009, 03:15 PM
Thanks a lot Shadab, it works the way you coded
however there is one little problem, if I register a variable in the code which is used in 'sidebar_1' template, I can't get it to show in the output using {vb:raw VariableInMySideBar} method
Your code was registering the variable with the main (TEST) template, instead of the sidebar template.
Try this:
##The variable to be used in 'my_sidebar_1' template
$ExVariable = 'SomeAutoGeneratedContent';
$mainTemplate = vB_Template::create('TEST');
$sidebar = vB_Template::create('sidebar_1');
$mainTemplate->register_page_templates();
$mainTemplate->register('navbar', $navbar);
$sidebar->register('VariableInMySideBar', $ExVariable);
$mainTemplate->register('my_sidebar_1', $sidebar->render());
print_output($mainTemplate->render());
AWMGolfer
11-15-2009, 07:57 PM
What would be really cool is if we could have the widgets display on these pages. The CMS is great and I will be using it but it just lacks in a few areas that a couple of quickly made pages using this would work great, then to add some widgets would just be perfect!
Adrian Schneider
11-16-2009, 04:38 AM
The new v4 code will be leaning towards that, though it'll be more of a transitional release. I don't see us coding "pages" like this for long... we should be able to tap into the routing, controllers, modules, etc.
AFAIK this part of the code is still highly volatile.
cory_booth
11-16-2009, 10:31 PM
This hack has saved me from loss of vbAdvanced!
Thanks soooo much. I was tearing up my head trying to figure out how to do this with the CMS. Yes, adding a widget or two would be perfect.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.