The Most Active and Friendliest
Affiliate Marketing Community Online!

“AdsEmpire”/  Direct Affiliate

Creating a custom page in vBulletin

  • Thread starter melkior_inactive
  • Start date
M

melkior_inactive

Guest
I've often seen people asking how to create a page inside vBulletin which would contain custom content.
And I had to do it myself a couple of times.

When in need of something like this people usually just save some vB page on their disk, edit it and upload it. This works OK, the page looks like the rest of your forum.
But, your user doesn't see the dynamic content (like wether he's logged in or not) and if you make modifications to the header, footer or CSS you'll need to make them on the static custom page as well.
That's OK if you have one page to take care of. But if you have multiple pages it gets boring and also too complicated.
And sometimes you'll need to modify the content of the custom page and you don't have access to the FTP of the site.
Well, this is how you create a page that will be the part of your vBuletin forum, and it's content will be located in a custom template so it makes it easy to modify.

First create a PHP file and name it as you'd like to call the page.
We'll use example.php. Create that file and put this code into it:
PHP:
<?php
  error_reporting(E_ALL & ~E_NOTICE);
 
 define('NO_REGISTER_GLOBALS', 1);
 define('THIS_SCRIPT', 'example');
 
 $phrasegroups = array();
 
 $specialtemplates = array();
 
 $globaltemplates = array(
 'CUSTOMPAGETEMPLATE'
 );
 
 $actiontemplates = array();
 
 require_once('./global.php');
 
 eval('$navbar = "' . fetch_template('navbar') . '";');
 eval('print_output("' . fetch_template('CUSTOMPAGETEMPLATE') . '");');
 
 ?>
First of all you need to do some modifications to the code above since this is only an example. 3 modifications are necessary to get your custom page going:
On line:
PHP:
define('THIS_SCRIPT', 'example');
You need to change example to the name of your custom page without the .php extension. So if you called your custom page dollhouse.php this line would read like this:
PHP:
define('THIS_SCRIPT', 'dollhouse');
Next two modifications are on lines 12 and 20.
Substitute CUSTOMPAGETEMPLATE with the name of the custom template you'll be creating in a second. It's best to call it descriptively so you'll find it easier, and know what it does.
Note the name cause you'll need it later.
If you're really interested, the code above communicates with the rest of the vBulletin and calls out the template you'll create. It also takes out the content from the template CUSTOMPAGETEMPLATE so it renders as the part of vBulletin.
OK, upload the file to your web server, in the forum's root folder.

You've got the page. Now you need content for it. Let's do it.
Go to your Admin CP, log in and select Styles & Templates from the left menu. Click on the Style Manager link. Find the name of your active style and select Add New Template from the drop down menu. Press Go if the page doesn't load automatically.
This part of the Admin CP allows you to create custom templates. And that is exactly what we want.
There are two fields you'll need to fill: title and content.
Remember the name of the custom template I said you should note? Write it under Title. In my example it would be CUSTOMPAGETEMPLATE.
And put this code under content:
PHP:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<!-- end no cache headers -->
<title><phrase 1="$vboptions[bbtitle]">$vbphrase[x_powered_by_vbulletin]</phrase></title>
<style type="text/css">
<!--
.top {
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-top-color: #000000;
	border-right-color: #000000;
	border-bottom-color: #000000;
	border-left-color: #000000;
}
.all {
	border: 1px solid #000000;
	background-color: #FFFFFF;
}
-->
</style>

$headinclude </head> <body> $header $navbar
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="$stylevar[cellspacing]" class="all">
  <thead>
    <tr align="center"> 
      <td align="left" valign="top" class="thead">
<div align="left"></div>
        <div align="left">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
            <tr>
              <td class="tcat">My super cool example page</td>
            </tr>
            <tr>
              <td>And this is my super cool content!</td>
            </tr>
          </table>
          <font size="2"><font face="Verdana, Arial, Helvetica, sans-serif"></font></font></div></td>
      <if condition="$vboptions[showmoderatorcolumn]"> </if> </tr>
  </thead>
  $forumbits 
  <tbody>
  </tbody>
</table>
$footer 
</body>
</html>
OK, this is your page. Change the name of the page on line 39 and the content on the line 42. You can put here anything you like. You'll notice that the actual content of the page is a table with two rows. The first row is the title of the page so keep it short and informative. The second row is the content of the page.
You can put anything you like here.
After you've designed your page press the Save button and you're off.
Navigate to the page to see if it's working and wether everything is OK.
Don't forget to link to the page! :)

One more important notice. Not all forums have just one style. In fact most of them have various skins and allow the members to choose the skin they like. If this is the case with your vBulletin forum, then you should create the same template in every active style and name it the same.
Once the user navigates to the page, the script itself will decide which template to use according to the skin the user has set.

If you see a white page when you navigate to your custom page it means that you either misspelled the name of the template, or you didn't create it at all.

Well that's about it.
 
I forgot to add, when a new version of vBulletin comes out, it might happen that you'll need to change the code a little bit but this should work for vB 3.5.4-3.6.5 (maybe others too).
 
I am already using this technique to create a Privacy Policy page for my Forum.

Thanx anyway ! :)
 
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.
 
banners
Back