Logo name

Ipb 2.1:Creating an act= page

From IpbWiki

  • Currently5.00/5
Jump to: navigation, search

Contents

Introduction

This tutorial will show you how to make an IPB "act=" page. This page will then be accessed by:

http://www.your-domain.com/forums/index.php?act=custom2

You need to download and backup the following files before we start:

  • index.php
  • init.php
  • cache/lang_cache/en/lang_online.php

You will be creating the following files in this guide:

  • sources/action_public/custom.php
  • cache/lang_cache/en/lang_custom.php

Step 1

The first thing you should do is create the source file. This is the file that calls the skin & lang file to display your content. Create a new PHP document using Dreamweaver or Notepad. Use this code as a basis for custom2.php:

CODE
<?php

//----------------------------------------
// If someone is trying to access this
// file directory, show the IPB
// error message
//----------------------------------------

if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}

//----------------------------------------
// Change "custom2" with your page title
// This ia always required
//----------------------------------------

class custom2
{
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";

//----------------------------------------
// Function: auto_run
//----------------------------------------

function auto_run()
{
global $ibforums, $DB, $std, $print;

//----------------------------------------
// This section loads your skin and
// language files. Change "custom2"
// to whatever you named your language
// and skin files.
//----------------------------------------

$ibforums->lang = $std->load_words($ibforums->lang, 'lang_custom2', $ibforums->lang_id );
$this->html = $std->load_template('skin_custom2');
$this->base_url = $ibforums->base_url;

//----------------------------------------
// You must change "custom2" here
// with the page name - this is how
// we grab and display the skin file
//----------------------------------------

$this->output = $this->html->show_custom2();

$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." :: ".$ibforums->lang['thispage_name'], 'JS' => 0, NAV => array( $ibforums->lang['thispage_name'] ) ) );

}
}
?>

Change what I have said in the comments to whatever you want.

Save the file as custom2.php and upload it to the following directory:

  • sources/action_public/

Step 2

It's time to create the lang_cache file. Create a new PHP document using Dreamweaver or any other text editor. Place this code in there:

CODE
<?php

$lang = array (

// Lang file for a custom page user posted image

'thispage_name' => "Custom Page 2",
'print_hello' => "Hello! This is my custom page.",

);
?>

Save the file as lang_custom2.php and upload it to the following directory:

  • cache/lang/en/

Step 3

Now it's time to modifiy some files. Open up index.php.

Find:

CODE
    'component'  => array( 'component'    , 'component' , array() ),

Add Below:

CODE
    'custom2' => array( 'custom2'   , 'custom2'   , array() ),

Remember to replace "custom2" with your page name. Example: If your page is a contact page, use this:

CODE
    'contact'  => array( 'contact'    , 'contact'    , array() ),

Save and upload the file to your forums directory.

Step 4

Open up ./cache/lang_cache/en/lang_online.php.

Find:

CODE
's_go' => "Update",

Add Below:

CODE
WHERE_custom2    => "Viewing a Custom Page",

Replacing "custom" with your custom page name, and "Viewing a Custom Page" with the description. Then save and upload the file to the following directory:[list] [*]cache/lang_cache/en/ [/list]Step 5 -

It's time to actually turn on custom pages. This is known as enabling legacy mode.

Open up ./init.php.

Find:

CODE
define( 'LEGACY_MODE', 0 );

Replace With:

CODE
define( 'LEGACY_MODE', 1 );

Save and Upload the file to your forums main directory.

Step 6 -

Time to create the auto-generated skin cache file. This is safely done through the ACP.

Login to the ACP, and navigate to the following:

  • LOOK & FEEL
  • Skin Manager > Edit Template HTML
  • All Global HTML

In the right frame of the template manager, scroll all the way to the bottom and you should see two buttons. Click the one that says Add Template Bit.

Fill in the following textboxes with this information:

  • New Template Bit Name - show_custom2
  • New Template Bit Incoming Data Variables - None
  • New Template Bit Group... - Leave default
  • Or Create New Group... custom2

Of course, replacing custom2 with your custom page name. Then click Continue.

The ACP now redirects you to the template bit edit area. In the big textarea, place this in there:

CODE
<div class="borderwrap">
 <div class="maintitle"><{CAT_IMG}>&nbsp;Custom Page 2</div>
 <table class='ipbtable' cellspacing="1">
  <tr>
   <th>My Custom Page</th>
  </tr>
  <tr>
   <td class="row2">
<!-- CONTENT -->

{ipb.lang['print_hello']}

<!-- END CONTENT -->

</td>
  </tr>
  <tr>
   <td style="padding: 3px; height: 0px;" class="catend"></td>
  </tr>
 </table>
</div>

Now save the template bit. If you have multiple skins installed, you must do this step to each skin. That's it! :)

Original Article Author: Fluffy

This page was last modified on 11 November 2006, at 15:06.  This page has been accessed 8,027 times.  Content is available under GNU Free Documentation License 1.2Disclaimers