Custom (ACT) Pages for IPB 1.3
This guide shows you how to make forum-like pages with your forum wrapper and hard-coded HTML content. Unfortunately, there is no nice and pretty interface for you to use to modify your content.
1. Backup!
Make a backup of your index.php file at the very least.
2. Edit index.php
Look for lines 334-388, a comment about deciding what to do. We will edit this array. PHP is syntax heavy, code slowly as proper syntax is easy to miss and hard to debug.
Look for:
//-------------------------------- // Decide what to do //-------------------------------- $choice = array( "idx" => "Boards", "SC" => "Boards", "SF" => "Forums", "SR" => "Forums", "ST" => "Topics", "Login" => "Login", //...etc... );
For every custom page you intend to create, you need a different act=... name for it. For example, if you wanted 2 pages, myforum.com/index.php?act=Rules, and myforum.com/index.php?act=GuideBook , your would add this to the bottom of your array. The array is case sensitive. Leave the right hand side of your array value alone, and don't change 'custompage'. Here, I create two pages:
//...etc... 'Store' => 'custompage', 'GuideBook' => 'custompage', );
3. Create sources/custompage.php
Create a new file called custompage.php that goes in the sources folder. Copy and paste the following code to get started.
<?php /* | The means and HTML hard-code for displaying custom pages on a forum software, | without the actual forum, and surrounded with your current skin's wrapper */ $idx = new custompage; class custompage { var $output = ""; var $page_title = ""; var $nav = array(); var $login_html = ""; var $modules = ""; function custompage() { //inform the PHP code of already existing global variables needed to construct the page global $ibforums, $DB, $std, $print, $skin_universal; //edit me accordingly //act=store_ic's page title $titleofcustompage = array( 'Store' => 'Purchase Mechanical Arms', 'GuideBook' => 'Guidebook & Rules & Mail Away Bride Forms', ); //edit me accordingly //this is the page that your browser will display, eg My board: IC Points $browserpagetitle = $ibforums->vars['board_name'].': '.$titleofcustompage; //if your act page is store_ic, you need to have a function called makepage_store_ic() that returns a string full of your html //you need a funciton in this manner for every custom act page $construct_function = 'makepage_' . $ibforums->input['act'] ; $custompage_content = $this->$construct_function(); //begin to put the page together, first load up our skin $this->html = $std->load_template('skin_boards'); //put together out page $this->output .= '<div class="custompage">' . $custompage_content . '</div>'; $print->add_output("$this->output"); $print->do_output( array( 'TITLE' => $browserpagetitle, 'JS' => 0, 'NAV' => $this->nav ) ); return; } function custompage_commonmenu(){ $menu = '<a href="#">page 1</a><a href="#">Page2</a>' return $menu; } function makepage_GuideBook(){ $content = ''; $content .= custompage_commonmenu() $content .= '<b>STORE</b>' $content .= '...' return $content; } function makepage_Store(){ $content = ''; $content .= custompage_commonmenu() $content .= '<b>STORE</b>' $content .= '...' return $content; } } ?>
4. Customize page titles
For every act page that you put into your index.php file, you'll probably want to define a custom page title that appears at the top of the user's browser bar (and on their tab) while they visit the page.
This part:
'Store' => 'Purchase Mechanical Arms', 'GuideBook' => 'Guidebook & Rules & Mail Away Bride Forms',
You can also change the way the title on the page is displayed, for example, adding prefixes.
You'd change this:
$browserpagetitle = $ibforums->vars['board_name'].': '.$titleofcustompage;
To something perhaps like this:
$browserpagetitle = $ibforums->vars['board_name'].' MYSITE GUIDEBOOK > '.$titleofcustompage;
5. Pretty Menu
I put in the code a place to make a menu so that all of your custom pages can be hooked together. You can edit that with the links for your pages, or other places in your forum. You can also do all sorts of CSS styling in here.
function custompage_commonmenu(){ $menu = '<a href="myforum.com/index.php?act=Staff">Staff Listing</a><br /> <a href="Templates">Site Posting Templates and Forms</a><br /> ' return $menu; }
If you don't want your pages to have a menu, just let the function return an empty string like this:
function custompage_commonmenu(){ return ''; }
6. Fill in your pages
For every page you create, you need to create a function called makepage_<page name>, taking no arguments and returning the proper HTML as a string. The function name should not have any spaces in it (Rules and Regulations would have to be makepage_rules or makepage_rulesAndRegulations). Remember that these things are case-sensitive. Perhaps something like this:
function makepage_Store(){ $content = ''; $content .= custompage_commonmenu() $content .= '<b>STORE</b>' $content .= '...' return $content; }
7. Upload, Try, and Revise
Remember that it is unlikely you will get everything right your first try. It is better to create one act page, and then go on to create all the rest. Try to just focus on one step at a time and don't worry about getting everything right all at once. When debugging, pay careful note of the error messages given and don't be afraid to increase your font size in your text-editor so that punctuation marks and syntax errors are more visible. You can always google an error message to see what it means. This is just the basic skeleton of what can be accomplished, don't be afraid to try new and great things!