The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[HOW TO - vB4] Create your own vBulletin page
This is an updated article on how to create your own vbulletin powered page. It's only for use with vB4. This is NOT my work. I'm posting this from another thread where vB Style took the time to write this out. And his work is based on the article by Gary King here - How to create your own vBulletin-powered page! (uses vB templates) Instructions to Create your Own Page: 1. Create the php page: - Create a new file, whatever you want to call it (let's say test.php). - Open up test.php and add the following (replace TEST with whatever template you want to show - WARNING: the template name is CASE SENSITIVE!!!): Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'test'); define('CSRF_PROTECTION', true); // 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 ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); require_once('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = construct_navbits(array('' => 'Test Page')); $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'My Page Title'; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('TEST'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); print_output($templater->render()); ?> 2. Create the Template: - If you are in debug mode, create the template in your MASTER STYLE so it shows up in all your styles, otherwise make sure you create the template in the style you are using. If following the page above, call the template TEST (WARNING: the template name is CASE SENSITIVE!!!) with the following content: 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} - {vb:raw pagetitle}</title> {vb:raw headinclude} {vb:raw headinclude_bottom} </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> Instructions to Add your Page to the Who's Online List (WOL): Create two plugins using the following hooks. Replace mypage and similar with your information. 1. hook location - online_location_process: Code:
switch ($filename) { case 'test.php': $userinfo['activity'] = 'mypage'; break; // add more cases here if you have more than one custom page. no need for multiple plugins. one plugin can handle all. } 2. hook location online_location_unknown: Code:
switch ($userinfo['activity']) { case 'mypage': $userinfo['where'] = '<a href="test.php?'.$vbulletin->session->vars[sessionurl].'">My Page</a>'; $userinfo['action'] = "Viewing My Page"; $handled = true; break; // add more cases here if you have more than one custom page. no need for multiple plugins. one plugin can handle all. } The colored part in the code above shows what you need to change in the plugins (both reds should be the same and both blues should be the same, whereas green can be whatever you want). Please see this article for help with rendering templates - [vB4] Rendering templates and registering variables - a short guide |
#1102
|
||||
|
||||
THIS_SCRIPT is the actual variable name, so...
HTML Code:
<vb:if condition="THIS_SCRIPT != 'custom page'">
PHP Code:
|
#1103
|
||||
|
||||
I did that and now for some reason getting this. It looks like all tags are closed, but obviously I'm missing one, lol.
The following error occurred when attempting to evaluate this template: Unclosed Tag This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish. |
#1104
|
||||
|
||||
I didn't look closely at the code, but you only want the tags around the specific code you are adding to your page and don't want doubled.
HTML Code:
<vb:if condition="THIS_SCRIPT != 'custom page'"> <meta name="description" content="test"> <meta name="keywords" content="test"> <meta name="author" content="I.G.O.T.A.?"> </vb:if> |
#1105
|
|||
|
|||
Quote:
I would appreciate any support that you are able to provide. Thank you, Code:
/* Copyright (c) 2009, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 2.7.0 */ html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var,optgroup{font-style:inherit;font-weight:inherit;}del,ins{text-decoration:none;}li{list-style:none;}caption,th{text-align: {vb:stylevar left};}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:baseline;}sub{vertical-align:baseline;}legend{color:#fff;}input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;}input,button,textarea,select{*font-size:100%;}body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}select,input,button,textarea,button{font:99% arial,helvetica,clean,sans-serif;}table{font-size:inherit;font:100%;}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%;} |
#1106
|
||||
|
||||
Quote:
For your list, create a custom class and use it to define the bullets |
Благодарность от: | ||
Lynne |
#1107
|
|||
|
|||
Should the samples listed in the first post work for a custom page when people aren't logged in?
Based on what was in the first post I've created the following, which seems to only work if I'm logged in. I need to setup a custom public page for people to sign up for various events. ACME_CUSTOM_PAGE_TEMPLATE 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} - {vb:raw pagetitle}</title> {vb:raw headinclude} {vb:raw headinclude_bottom} </head> <body> {vb:raw header} {vb:raw navbar} <h2 id="acme_bannerTitle"class="blockhead">{vb:raw bannerTitle}</h2> <div class="blockbody"> <div class="blockrow"> <div id="acmeContents"> {vb:raw my_var} </div> </div> </div> {vb:raw footer} </body> </html> Code:
<?php $tabScriptName = 'PublicTabScript'; $pagetitle = 'ACME Public ($pagetitle)'; $phpFile = './acme_custom/acme_public.php'; $navTitle = 'Public Tab'; $bannerTitle = 'Public Page Example'; require_once($_SERVER['DOCUMENT_ROOT'] . "/acme_custom/acme_vb.php"); ?> Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', $tabScriptName); define('CSRF_PROTECTION', true); // 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('ACME_CUSTOM_PAGE_TEMPLATE'); // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); chdir($_SERVER['DOCUMENT_ROOT']); require_once('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = construct_navbits(array('' => $navTitle)); $navbar = render_navbar_template($navbits); // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### ?> <?php ob_start(); include($phpFile); $includedphp = ob_get_contents(); ob_end_clean(); $my_var .= $includedphp; $templater = vB_Template::create('ACME_CUSTOM_PAGE_TEMPLATE'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); $templater->register('bannerTitle', $bannerTitle); $templater->register('my_var', $my_var); print_output($templater->render()); ?> Code:
<div> This is my public page. </div> |
#1108
|
|||
|
|||
Based on the code you posted, I don't see anything out of the ordinary that should cause such thing to happen.
|
#1109
|
|||
|
|||
ARGH!!!
Nothing to see here, move along. I figured it out. My template is currently only applied to one style. When I'm not logged in and visit the page, the style where my template is not selected. When I select the style then click on my "Public" tab, then everything works. |
#1110
|
||||
|
||||
Quote:
|
#1111
|
|||
|
|||
OK I'm back again. Everything seems to work fine for me on my local machine, but I ran into 404 errors when trying my code on my live site.
On my live site vBulletin is loaded directly under httpdocs folder. I have placed all of my code under httpdocs/acme_custom. When I load the page all of the styling is off, and upon further investigation I have a bunch of 404 errors, and none of the standard vBulletin links like Forum or Contact Us work. If I place my custom php file (acme_vbPublic.php) in httpdocs then everything works. I performed a chgdir prior to the globl.php, so I'm not sure where I've gone wrong. Code:
chdir($_SERVER['DOCUMENT_ROOT']); require_once('./global.php'); If I inspect the 404 errors, the request url is http://my-site.ca/acme_custom/client...event.js?v=423 I do not reference any of those resources that have 404 errors, I'm assuming that they are part of the global.php script. Any clues? I'd prefer to keep all of my code under the acme_custom directory. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|