It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a Donation to help aid in operating costs.

Creating a New UBB.threads Page

What Is Covered

Summary
Example Files
     • Example Language File
     • Example Script File
     • Example Template File


 

Summary


Creating a new system (page) in UBB.threads can be a challenge, even to a vested veteran; but examples are everywhere within the system once you know how to utilize it.
Note
Initially, there was a set of sample files supplied with the UBB.threads stock archive, but a previous developer had removed the file to save (very little) space. This article was initially inspired by those sample files.


Each system in UBB.threads has (at least) three parts:
• The Language file (/languages/english/example.php) - The language file, containing all of the strings that your new page will be using.
• The Script file (/scripts/example.inc.php) - The script file, containing all of the PHP that your script will be utilizing.
• The Template File (/templates/default/example.tpl) - The template file, which contains the overall outline of how your script is presented.

Likewise, each Admin system has three parts:
• The Language file (/languages/english/admin/example.php) - The admin language file, containing all of the strings that your new page will be using.
• The Script file (/admin/example.inc.php) - The admin script file, containing all of the PHP that your script will be utilizing.
• The Template File (/templates/default/admin/example.tmpl) - The admin template file, which contains the overall outline of how your script is presented.

Additionally, one can opt to utilize the "Extra CSS" section of the style editor to add any additional styling options that your new page will need.
Note
If you're accessing a page, the template/script/language file is commonly listed in your address bar, such as:
Active Topics: ubbthreads.php/activetopics/7/1.html



 

Example Files


We generally recommend that you learn how the system itself works by looking at the various files included with your install, but getting started can be a caveat; we've produced the below Sample Files so that you know how to get started. For the sake of simplicity we've named everything "sample" where you'll need to simply rename to fit your page.


 

Example Language File

(/languages/english/example.php)
Code
<?php
$ubbt_lang['HEADER'] = "This is a simple heading.";
$ubbt_lang['STRING'] = "This is the string used in our example!";
$ubbt_lang['TITLE'] = "This is the title of the page!";
?>



 

Example Script File

(/scripts/sample.inc.php)
Code
<?php defined("UBB_MAIN_PROGRAM") or exit;
/*
Version: 7.6.0
Purpose: Sample Page
Future: 1. Build Example, 2. Give Away Example, 3. ???, 4. Profit.
*/

function page_example_gpc() {
return array(
"input" => array(
// Set your $_GET or $_POST variables here
"page" => array("page","get","int"),
"section" => array("section","get","alpha"),
),
"wordlets" => array("example"), // Any language file that needs to be loaded
"user_fields" => "",
"regonly" => 0, // Registered Users Only?
"admin_only" => 0, // Admin Only?
"admin_or_mod" => 0, // Admin or Moderator Only?
);
}

function page_example_run() {
global $tree, $userob, $user, $in, $ubbt_lang, $config, $forumvisit, $visit, $dbh, $html, $style_array;
extract($in, EXTR_OVERWRITE | EXTR_REFS);

// Your PHP coding would go here, and can adjust any variables below; please use the existing script pages in the install archive for examples.
$hello = "Howdy!";

// The $smarty_data definition is a listing of items that you're going to allow the template manager to use, it's an array of "item name" => "payload".
$smarty_data = array(
"hello" => $hello,
);

// Below we have the items that build our page
$cfrm = make_ubb_url("ubb=cfrm", "", false);
return array(
"header" => array (
"title" => "{$ubbt_lang['TITLE']}",
"refresh" => 0,
"user" => $user,
"Board" => "",
"javascript" => "",
"bypass" => 0,
"onload" => "",
"breadcrumb" => "<a href="{$cfrm}">{$ubbt_lang['FORUM_TEXT']}</a> &raquo; {$ubbt_lang['TITLE']}",
),
"template" => "sample",
"data" => & $smarty_data,
"footer" => true,
"location" => "",
);
}
?>



 

Example Template File

(/templates/default/example.tpl)
Code
{*
Version: 7.6.0
Purpose: Example Page
Future: 1. Build Example, 2. Give Away Example, 3. ???, 4. Profit.
*}
{$tbopen}
<tr>
<td class="tdheader">
{$lang.HEADER}
</td>
</tr>
<tr>
<td class="alt-1">
{$hello}
<br><br>

{$lang.STRING}
</td>
</tr>
{$tbclose}

Posted on July 30th, 2016 · Updated on January 13th, 2017
▼ Sponsored Links ▼
▲ Sponsored Links ▲

Comments

( Posted)

Related Content

▼ Sponsored Links ▼
▲ Sponsored Links ▲
For the best viewing experience please update your browser to Chrome, Firefox, or Opera