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 |
#662
|
|||
|
|||
ok, about to pull my hair out here. I need for the content (in this case a podcast) to show up on a RSS Feed. Just like the forums would, but for this custom page. How do I go about doing that?
|
#663
|
||||
|
||||
You would need to edit the external.php page to do this. That is beyond the scope of this article though.
|
#664
|
|||
|
|||
//edit: Sorry used the wrong Tab to post, should be in another topic.
|
#665
|
|||
|
|||
Anyone have an idea why I can't get this script warking with this page but can on main forum section?
Code:
<body> <form name="form" id="form"> <label for="day">day</label> <select id="day" name="day" onchange="updateDept();"></select> <label for="month">month</label> <select id="month" name="month" onchange="updateDay(this.value);updateDept();"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <label for="year">year</label> <select id="year" name="year" onchange="updateDept();"> <option value="2011">2011</option> <option value="2012">2012</option> </select> <input type="hidden" name="departureDate" id="departureDate" value="" /> <p> <label for="duration">Duration</label> <select name="duration" id="duration"> <option value="7">1 week</option> <option value="14">2 Weeks</option> <option value="1">1 day</option> <option value="2">2 days</option> <option value="3">3 days</option> <option value="4">4 days</option> <option value="5">5 days</option> <option value="6">6 days</option> <option value="7">7 day</option> <option value="8">8 days</option> <option value="9">9 days</option> <option value="10">10 days</option> <option value="11">11 days</option> <option value="12">12 days</option> <option value="13">13 day</option> <option value="14">14 days</option> <option value="15">15 days</option> <option value="16">16 days</option> <option value="17">17 days</option> <option value="18">18 days</option> <option value="19">19 day</option> <option value="20">20 days</option> <option value="21">21 days</option> <option value="22">22 days</option> <option value="23">23 days</option> <option value="24">24 days</option> <option value="25">25 day</option> <option value="26">26 days</option> <option value="27">27 days</option> <option value="28">28 days</option> </select> </p> <input type="hidden" name="dateXSell" id="dateXSell" value="7" /> <p> <label for="departureAirportCode">Departure airport</label> <select name="departureAirportCode" id="departureAirportCode"> <option value="*LN">Any London Airports</option> <option value="*SE">Any South-East</option> <option value="*SW">Any South-West</option> <option value="*MD">Any Midlands</option> <option value="*NE">Any North-East</option> <option value="*NW">Any North-West</option> <option value="*WA">Any Wales</option> <option value="*SC">Any Scotland</option> <option value="*NI">Any Northern Ireland</option> <option value="ABZ">Aberdeen</option> <option value="BFS">Belfast Intl</option> <option value="BHX">Birmingham Intl</option> <option value="BLK">Blackpool</option> <option value="BOH">Bournemouth</option> <option value="BRS">Bristol</option> <option value="CWL">Cardiff</option> <option value="DSA">Doncaster Sheffield</option> <option value="MME">Durham Tees Valley</option> <option value="EMA">East Midlands</option> <option value="EDI">Edinburgh Intl</option> <option value="EXT">Exeter</option> <option value="GLA">Glasgow Intl</option> <option value="HUY">Humberside</option> <option value="INV">Inverness</option> <option value="LBA">Leeds Bradford</option> <option value="LPL">Liverpool Intl</option> <option value="LGW">London Gatwick</option> <option value="LHR">London Heathrow</option> <option value="LTN">Luton</option> <option value="MAN">Manchester</option> <option value="NCL">Newcastle</option> <option value="NWI">Norwich</option> <option value="PIK">Prestwick</option> <option value="SOU">Southampton</option> <option value="STN">Stansted</option> </select> </p> <p> <label for="tuiCtryCode">Destination</label> <select name="tuiCtryCode" id="tuiCtryCode"> <option value="Any">Any Destinations</option> <option value="BGR">Bulgaria</option> <option value="BGR,002682"> - Bourgas</option> <option value="BGR,002683"> - Varna</option> <option value="HRV">Croatia</option> <option value="HRV,001505"> - Croatia</option> <option value="CPV">Cape Verde</option> <option value="CPV,003837"> - Cape Verde</option> <option value="CUB">Cuba</option> <option value="CUB,000744"> - Cuba</option> <option value="CYP">Cyprus</option> <option value="CYP,000791"> - East</option> <option value="CYP,001443"> - West</option> <option value="DOM">Dominican Republic</option> <option value="DOM,001451"> - East</option> <option value="DOM,000832"> - North</option> <option value="DOM,001452"> - South</option> <option value="EGY">Egypt</option> <option value="EGY,000846"> - Nile</option> <option value="EGY,001689"> - Red Sea</option> <option value="GMB">Gambia</option> <option value="GMB,000862"> - Gambia</option> <option value="GRC">Greece</option> <option value="GRC,000691"> - Corfu</option> <option value="GRC,000800"> - Crete</option> <option value="GRC,000840"> - Halkidiki</option> <option value="GRC,002554"> - Ithaca</option> <option value="GRC,000864"> - Kefalonia</option> <option value="GRC,000899"> - Kos</option> <option value="GRC,000910"> - Lefkas</option> <option value="GRC,003209"> - Meganissi</option> <option value="GRC,003211"> - Messinia</option> <option value="GRC,003215"> - Monemvasia & Nauplion</option> <option value="GRC,003218"> - Paralio Astros</option> <option value="GRC,000915"> - Parga</option> <option value="GRC,002173"> - Paxos</option> <option value="GRC,003684"> - Pelion</option> <option value="GRC,000923"> - Rhodes</option> <option value="GRC,000935"> - Samos</option> <option value="GRC,000939"> - Santorini</option> <option value="GRC,000941"> - Skiathos</option> <option value="GRC,000134"> - Skopelos</option> <option value="GRC,000947"> - Thassos</option> <option value="GRC,003236"> - The Mani</option> <option value="GRC,000952"> - Zakynthos</option> <option value="IND">India</option> <option value="IND,001915"> - Goa</option> <option value="ITA">Italy</option> <option value="ITA,003413"> - Calabria</option> <option value="ITA,003641"> - Cilento</option> <option value="ITA,000672"> - Neapolitan Riviera</option> <option value="ITA,002891"> - Puglia</option> <option value="ITA,000678"> - Sardinia</option> <option value="ITA,000681"> - Sicily</option> <option value="ITA,000687"> - Tuscan Riviera</option> <option value="ITA,002230"> - Tuscany</option> <option value="ITA,003023"> - Umbria</option> <option value="ITA,000695"> - Venetian Riviera</option> <option value="JAM">Jamaica</option> <option value="JAM,000148"> - Jamaica</option> <option value="KEN">Kenya</option> <option value="KEN,000132"> - Kenya</option> <option value="MDV">Maldives</option> <option value="MDV,000548"> - Maldives</option> <option value="MLT">Malta</option> <option value="MLT,000552"> - Gozo</option> <option value="MLT,000555"> - Malta</option> <option value="MEX">Mexico</option> <option value="MEX,000577"> - Caribbean Coast (Mexico)</option> <option value="MAR">Morocco</option> <option value="MAR,001005"> - Agadir</option> <option value="PRT">Portugal</option> <option value="PRT,000154"> - Algarve</option> <option value="PRT,000157"> - Madeira</option> <option value="YUG">Serbia & Montenegro</option> <option value="YUG,002760"> - Montenegro</option> <option value="SVN">Slovenia</option> <option value="SVN,001009"> - Slovenia</option> <option value="ESP">Spain</option> <option value="ESP,002894"> - Andalucia</option> <option value="ESP,000347"> - Costa Blanca</option> <option value="ESP,000351"> - Costa Brava</option> <option value="ESP,002150"> - Costa De La Luz</option> <option value="ESP,000365"> - Costa Del Sol</option> <option value="ESP,000372"> - Costa Dorada</option> <option value="ESP,000312"> - Fuerteventura</option> <option value="ESP,000318"> - Gran Canaria</option> <option value="ESP,000242"> - Ibiza</option> <option value="ESP,000329"> - Lanzarote</option> <option value="ESP,000122"> - Majorca</option> <option value="ESP,000127"> - Minorca</option> <option value="ESP,000335"> - Tenerife</option> <option value="TUN">Tunisia</option> <option value="TUN,000431"> - Tunisia</option> <option value="TUR">Turkey</option> <option value="TUR,001379"> - Antalya</option> <option value="TUR,001559"> - Bodrum</option> <option value="TUR,000442"> - Dalaman</option> <option value="USA">United States Of America</option> <option value="USA,000207"> - Florida</option> </select> </p> <input type="hidden" name="tuiDestCode" value="" /> <input type="hidden" name="tuiResortCode" value="" /> <input type="hidden" name="tuiAccomCode" value="" /> <p id="destCode"></p> <input type="hidden" name="rating" value="0" /> <!-- Rooms --> <p> <label for="numberOfRooms">Number of rooms</label> <select id="numberOfRooms" name="numberOfRooms" onchange="addRooms(this.value)"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </p> <div id="rooms"> <div id="rooms1"> <label>Room 1</label> <div id="adult1"> Adults <select id="adultRooms1"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select> </div> <div id="child1"> Children <select id="childRooms1" onchange="addChildAges(this.value,1)"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> </select> </div> </div> </div> <input type="hidden" name="accommodationType" value="Any" /> <input type="hidden" name="theme" value="" /> <input type="hidden" name="numAdults" value="" /> <input type="hidden" name="numChildren" value="" /> <input type="hidden" name="childInfantAges" value="0"/> <br /> <script type="text/javascript"> document.writeln('<a hr' + 'ef=\"#\" onclick=\"return removed();\">search<\/a>'); </script> </form> <script type="text/javascript" src="http://www.removed/scripts/affiliates/aol.js"></script> <script> function generate_url(){ var form = document.getElementById('form'); var url = 'http://www.removed/page/byo/search/dlresults.page?'; /* once all of the form values have been set append them to the url */ for(var i=3;i<form.elements.length;i++) { if(form.elements[i].name) { url+=form.elements[i].name+'='+form.elements[i].value; if(i!=form.length-1) { url+='&'; } } } url = 'http://www.removedcode?SID=&URL=' + escape(url); window.open(url); } </script> </body> </html><img src="http://www.removedcode" width="1" height="1" border="0"/> |
#666
|
||||
|
||||
What is that code supposed to be for? It doesn't follow the template example that I gave in the first post. And, it certainly isn't a proper html page, so exactly what is it and what does it have to do with this article?
|
#667
|
|||
|
|||
Lynn,
I can't get this to work. I am on vb 4.1.5. Here's what I have done. PHP File Code: Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'devices'); 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('devices', ); // 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('' => 'Devices')); $navbar = render_navbar_template($navbits); // ###### YOUR CUSTOM CODE GOES HERE ##### $pagetitle = 'Devices'; echo hi; // ###### NOW YOUR TEMPLATE IS BEING RENDERED ###### $templater = vB_Template::create('devices'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); print_output($templater->render()); ?> 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> location process Code:
switch ($filename) { case 'devices.php': $userinfo['activity'] = 'Devices'; break; // add more cases here if you have more than one custom page. no need for multiple plugins. one plugin can handle all. } Code:
switch ($userinfo['activity']) { case 'Devices': $userinfo['where'] = '<a href="devices.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. } Thanks in advance |
#668
|
||||
|
||||
Did you add the template to each of your styles? If one style doesn't have it, and you're viewing the forum in that style, you'll just get a blank page.
|
#669
|
||||
|
||||
To add to Mark's comment, you cannot use echo in your php and have it show up in the correct spot in your template. You need to assign any output to a variable that you then register for use in your template.
|
#670
|
|||
|
|||
Quote:
Quote:
Thanks for your replies, I will add the template to each of the styles to see what that does. EDIT: Adding the template to all the styles fixed it...Thanks a lot! |
#671
|
|||
|
|||
Sorry but I'm unable to follow these instructions, it's really confusing.
--------------- Added [DATE]1317740356[/DATE] at [TIME]1317740356[/TIME] --------------- I want a navtab that displays a copy of my forumhome but without it's contents. --------------- Added [DATE]1317748066[/DATE] at [TIME]1317748066[/TIME] --------------- Ok I have created the new page but I can only see it when I type in the exact url in the address bar, there is no navbar tab. This new page I want is just to display a single youtube int he center but I can't figure it out, any help? Thanks. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|