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 |
#752
|
|||
|
|||
The page should look like this.
http://www.xvgaming.com/games/stats/bfstats.php And here is the (second page) using this article to create the template http://www.xvgaming.com/bfstatsbynam...M_0:0:21788544 Here is the php file (standalone) that makes it like bfstats.php PHP Code:
Atleast thats what i think is wrong with it. Here is the link and the php/template files http://www.xvgaming.com/bfstats.php PHP Code:
Code:
{vb:stylevar htmldoctype} <html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"> xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if> dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html"> <head> <LINK REL=StyleSheet HREF="games/stats/player_stats.css" TYPE="text/css"> {vb:raw headinclude} <title>{vb:raw pagetitle}</title> <vb:if condition="$includecss"> <vb:if condition="$vboptions['storecssasfile']"> <vb:each from="includecss" value="file"> {vb:cssfile {vb:raw file}} </vb:each> <vb:else /> {vb:cssfile {vb:raw includecss}} </vb:if> </vb:if> {vb:raw headinclude_bottom} </head> <body> {vb:raw header} {vb:raw navbar} <div id="content"> <div id="topbar"> <div id="prevlink"> {vb:raw prevlink}{vb:raw prevstatspage}{vb:raw prevlink2} </div> <div id="steamform"> <form method="get" action="http://www.xvgaming.com/bfstatsbyname.php"> <label>Enter Your SteamID:</label> <input type="text" maxlength="20" name="SteamID" value="STEAM_0:1:23456789" onFocus="if(value == 'STEAM_0:1:23456789') {value=''}" onBlur="if(value=='') {value='STEAM_0:1:23456789'}"/> <button type="submit">Submit</button> <div class="spacer"></div> </form> </div> <div id="nextlink"> {vb:raw nextlink}{vb:raw nextstatspage}{vb:raw nextlink2} </div> <div class="spacer"></div> </div> <table class="stats"> <tr> <th class="stats">Rank</th> <th class="stats">Name</th> <th class="stats">XP</th> <th class="stats">Assault</th> <th class="stats">Special Ops</th> <th class="stats">Sniper</th> <th class="stats">Engineer</th> <th class="stats">Medic</th> <th class="stats">Support</th> </tr> {vb:raw starttablerow} {vb:raw starttablecell1}{vb:raw RankNumber}{vb:raw endtablecell1} {vb:raw starttablecell2}{vb:raw player_id}{vb:raw tablecell2center}{vb:raw player_name}{vb:raw endtablecell2} {vb:raw starttablecell3}{vb:raw player_total_xp}{vb:raw endtablecell3} {vb:raw starttablecell4}{vb:raw player_class_assault_xp}{vb:raw endtablecell4} {vb:raw starttablecell5}{vb:raw player_class_specops_xp}{vb:raw startendtablecell5} {vb:raw starttablecell6}{vb:raw player_class_sniper_xp}{vb:raw endtablecell6} {vb:raw starttablecell7}{vb:raw player_class_engineer_xp}{vb:raw endtablecell7} {vb:raw starttablecell8}{vb:raw player_class_medic_xp}{vb:raw endtablecell8} {vb:raw starttablecell9}{vb:raw $player_class_support_xp}{vb:raw endtablecell9} {vb:raw endtablerow} </table> <div class="spacer"> </div> </div> <div class="spacer"></div> {vb:raw footer} </body> </html> Thanks abunch in advanced. |
#753
|
||||
|
||||
Why are you doing all these start and stop table rows? Why not just:
PHP Code:
HTML Code:
{vb:raw starttablecell1}{vb:raw RankNumber}{vb:raw endtablecell1} {vb:raw starttablecell2}{vb:raw player_id}{vb:raw tablecell2center}{vb:raw player_name}{vb:raw endtablecell2} .... {vb:raw starttablecell9}{vb:raw $player_class_support_xp}{vb:raw endtablecell9} HTML Code:
{vb:raw output} |
#754
|
|||
|
|||
That worked perfectly. And to answer your question This was my first dabble in PHP and MySql. Im trying to teach it to my self and work on different things. So THANKS a ton.
I have a friend that wants to make a chrome widget that will alert him to new PM's and thread subscriptions on a VB forum so im learning some things about php and vb. |
#755
|
|||
|
|||
thanks i like this
|
#756
|
|||
|
|||
I am still hoping for help. I have implemented dozens and dozens of pages using this process with lots of customization. Thanks Lyne. I have embedded newsfeeds, slideshows, spreadsheets, and etc. So I am fairly familiar with the method.
I am having trouble with one implementation. It looks beautiful, but it doesn't recognize me as logged in user. I call the test.php (using the demo model terminology from the original post in this article) from another page, let's call that index.php (really a complex application). If I require_once global.php on test.php, it doesn't work (printing variables shows me as a guest). I can require_once global.php on index.php and it works and shows me as logged in. I can pass the security token obtained from index.php to either test.php via an assign function in that application has very similar to the templater register used by VB for test.php. I have seen the security value on the test.php (printing variables) and have rendered the security value into the template html output. The result is that whenever I render an html page from this system (index.php calls test.php which uses template TEST to create an html page) it shows me as not logged in and the page source shows me as a guest. If I navigate to another forum page, I am still logged in. So here are some questions and hopefully I can get some help for further study: (1) If I can get a security token in the world of index.php such as PHP Code:
HTML Code:
<input type="hidden" name="securitytoken" value="{tokenkb}" />
One of two options, in my mind. I am either doing something wrong with passing the security token in terms of the input statement. Do I need to pass more than the security token? -or- index.php is disabling or clearing the session so the security token doesn't log me into the system. Interestingly, remember that if I navigate to another forum page I am still logged in and everything is fine. Does anyone have a suggestion on how to pass the security token. Does the syntax look OK. I have never unlocked a page in this manner. Or is there a command or series of command I can search through in the world of index.php that would disable (temporarily) the session so it can't recognize a user as logged in. I might be able to disable or adjust this function. Any advice or suggestions would be much appreciated. |
#757
|
||||
|
||||
Why are you focusing on passing the securitytoken? What about the userid - that is the variable you need.
|
#758
|
|||
|
|||
Quote:
My hack around this is to modify header to skip that assessment for this page (THIS_SCRIPT test) and not show anything in the upper right corner and to modify Navbar in the same manner to skip the messages for this page. So it's not elegant but it sort of works. The problem is that there are times that I get logged out after viewing this page (weird inconsistent behavior of tokens I think and browser caches). My thought is that if I could log myself back in after going through this other application, which apparently tries to flush the session or some sort of thing, I would be golden and this page would work like the dozens of others and I wouldn't have to worry about being logged out. So I thought if I used the security token I could log myself back in. This would be the cleanest approach forward. Any suggestions on how to do this, assuming you agree on the approach. I have seen some threads on remote login. Should I implement this on the test.php? Suggested thread for VB4 to help me do this? My security token notes were related to a post that Lynne made on this thread to use <input ...>. If I can't get this to work, my latest brainstorm is to experiment with merging index.php (the launch code for the other application) and test.php (the code for rendering VB pages via the tutorial Lynne pulled together). I don't like this approach since it will be difficult to maintain through updates of the other application, even assuming I can get it to work. The other application renders global variables into templates as well. I think it was already a miracle that I could get the other application to call test.php and have them both render things into the TEST template. Suggestions on approaches to stay logged in would be appreciated! --------------- Added [DATE]1327535262[/DATE] at [TIME]1327535262[/TIME] --------------- Additionally, does anyone have any idea of what types of php commands in the other application might be logging me off the vbulletin system? I might be able to search for those and circumvent them. Thanks. |
#759
|
|||
|
|||
I've recently built a new page and want to put in ad locations. There's something about the variable "$ad_location" that won't let me do it. "$bad_location" works though. Is there some special handling you have to do to use that variable name?
|
#760
|
|||
|
|||
What do you mean by "won't let you do it"? Where are you trying to use that variable?
|
#761
|
|||
|
|||
Well, the problem I'm having is that I don't use ads on my own forum but I'm working on a new page for someone else who does. So I don't know much about how to place ads, and it's hard to design a page that uses them and get a new set of locations in the adminCP. Anyway I'm fumbling my way through this by trial and error.
"$ad_location" seems to be reserved by vBulletin so you can't just use it any way you want. But as I said, I'm figuring this out. I wish you could search for "ad location" but "ad" is too short!!!!!! If I ever get this working maybe I should write an article. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|