vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Custom page Script... (https://vborg.vbsupport.ru/showthread.php?t=227974)

MarkFoster 11-14-2009 11:53 PM

Custom page Script...
 
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?
Code:

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

<?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());

?>

HTML Code:

{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

Quote:

Originally Posted by vB Style (Post 1914389)
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 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());

?>

HTML Code:

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

error_reporting(E_ALL & ~E_NOTICE); 

Should be
PHP Code:

error_reporting(E_ALL & ~E_NOTICE & ~8192); 


Dismounted 11-15-2009 02:25 AM

Quote:

Originally Posted by HMBeaty (Post 1914392)
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

Quote:

Originally Posted by Dismounted (Post 1914411)
No need to suppress E_DEPRECATED warnings now, as they should be fixed.

Ok, sounds good. :) Thank you Dismounted

Cip 11-15-2009 05:09 AM

vB Style is god vBulletinized. :)

ragtek 11-15-2009 07:41 AM

Quote:

Originally Posted by vB Style (Post 1914389)
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 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());

?>

HTML Code:

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

$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

Quote:

Originally Posted by winstone (Post 1914477)
what does following function do?
PHP Code:

$templater->register_page_templates(); 


It makes the header, footer and headinclude templates available to the template being evaluated.

Quote:

Originally Posted by winstone (Post 1914477)
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]

PHP Code:

$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

Quote:

Originally Posted by ragtek (Post 1914475)
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.
PHP Code:

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

{vb:raw my_sidebar_1}
works fine

in 'sidebar_1' template:
Code:

{vb:raw VariableInMySideBar}
doesn't work

and surprisingly
Code:

{$ExVariable}
works fine, but I guess I shouldn't use it like that

cellarius 11-15-2009 10:59 AM

Quote:

Originally Posted by ragtek (Post 1914475)
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
PHP Code:

define('CSRF_PROTECTION'true); 

after
PHP Code:

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

Quote:

Originally Posted by HMBeaty (Post 1914392)
Actually, to make a quick correction (if I remember correctly)...

This
PHP Code:

error_reporting(E_ALL & ~E_NOTICE); 

Should be
PHP Code:

error_reporting(E_ALL & ~E_NOTICE & ~8192); 


Quote:

Originally Posted by Dismounted (Post 1914411)
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

Quote:

Originally Posted by winstone (Post 1914536)
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:

PHP Code:

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


All times are GMT. The time now is 06:44 AM.

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.03754 seconds
  • Memory Usage 1,875KB
  • 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
  • (4)bbcode_code_printable
  • (3)bbcode_html_printable
  • (15)bbcode_php_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)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