Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
+ Reply to Thread
Results 1 to 5 of 5

Thread: Creating a custom page in vBulletin

  1. #1
    melkior_inactive Guest

    Default Creating a custom page in vBulletin

    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 Code:
    <?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 Code:
    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 Code:
    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 Code:
    $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-width1px;
        
    border-right-width1px;
        
    border-bottom-width1px;
        
    border-left-width1px;
        
    border-top-stylesolid;
        
    border-top-color#000000;
        
    border-right-color#000000;
        
    border-bottom-color#000000;
        
    border-left-color#000000;
    }
    .
    all {
        
    border1px 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.

  2. #2
    melkior_inactive Guest

    Default

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

  3. #3
    gkd_uk is offline Super Moderator gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of
    Join Date
    Mar 2007
    Location
    UK
    Posts
    2,550

  4. #4
    Shadab's Avatar
    Shadab is offline Member Shadab is on a distinguished road
    Join Date
    Dec 2007
    Location
    Bhopal (India)
    Posts
    60

    Default

    I am already using this technique to create a Privacy Policy page for my Forum.

    Thanx anyway !

  5. #5
    GrAveTzT's Avatar
    GrAveTzT is offline Junior Member GrAveTzT is on a distinguished road
    Join Date
    Apr 2008
    Posts
    13

    Default

    This was very usful for me!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Tips for creating better website
    By temi in forum Webmaster Tips and Tricks
    Replies: 11
    Last Post: 03-21-2008, 01:25 AM
  2. Getting a welcome box on the first page in vBulletin?
    By Stephanie in forum General Webmaster Talk
    Replies: 8
    Last Post: 08-05-2007, 12:55 PM
  3. Creating Banners
    By gkd_uk in forum General Webmaster Talk
    Replies: 1
    Last Post: 05-26-2007, 10:36 AM
  4. Creating your own blog
    By melkior_inactive in forum General Webmaster Talk
    Replies: 17
    Last Post: 05-17-2007, 10:29 PM
  5. [Sale] Smooth & Sexy vBulletin Skin with custom postbit
    By TheWebJunkie in forum Marketplace (all other buy/sell/wanted)
    Replies: 4
    Last Post: 04-04-2005, 11:03 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124