Create a standalone Custom Page

From e107 Wiki
Jump to: navigation, search

e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page


Current Release 1.0.4 | | Download | Changelog | Forum | Plugins | Themes | RSS Feed of Latest Changes | Atom Feed of Latest Changes

Frequently Asked Questions Section of e107 handbook
Main page > I : First Aid > II : Development > III : Administration > IV : How To's > V : Plugin Writing > VI : Theming & Shortcodes

This page is a stub. You can help e107 by expanding it.


Custom pages and menus are normally stored in the database, and given names such as:

There are circumstances where it is more convenient to create a custom page as a separate file; typically because fairly extensive code is required.

This can readily be achieved using the structure described here.

Overall Page Structure

Code: mycustompage.php

$caption = "Title of your Page";
$text = "

Your text etc. here using single quotes ' only or for doubles \" escaped with \"


$caption = $tp->toHtml($caption);
$text = $tp->toHtml($text);

$ns -> tablerender($caption, $text);

Create a new file using the template above on your PC using a good text editor, and populate the $text variable with the required HTML. This can be done in a single step, or in multiple steps, using php code as required.

Note that you will need to edit the location of your class2.php in this line of the above code require_once("class2.php");

For most plugins, replacing "class2.php" with "../../class2.php" will work.

Once created, upload to your sites root folder via FTP and add a link to it from admin>>sitelinks if required.

Using Shortcodes in the text

If you want to use the standard shortcodes in your file, replace the line:

$text = $tp->toHtml($text);


$text = $tp->toHtml($text, TRUE, 'parse_sc, constants');

(There are other options; refer to documentation on the $tp->toHtml() function for further information).

Linking to the page

Once created, you can specify links to the page in the normal way; for example:


Or add a link in admin>>sitelinks

Using images from your theme in the page

If you want to use an image that is saved in your theme images folder use


Code: Including images from your theme
<img src='{THEME}images/mypicture.gif' width='32' height='33'>

Using php code in the page

If you want to build a flexible custom page you will probably need php code. This is very straightforward (if you know php) since a standalone custom page is already written in php.

Lines such as the one beginning "$text = ...." are php code statements.

To take a simple example, you can build up your HTML text using several php statements:

Code: simple php example
$text = "This is a line<br />";    // First line
$text.= "This is the second line<br />";
$text .= "This is the third line<br />";

To keep things simple, put this code after all the 'include' statements, and before the statement which displays it. (Once you know php better, all sorts of things are possible)

From this simple start, it is possibly to build more complex php code, where you get information from databases, do calculations and so on.

Simple Page Construction

This method will usually work if your content is 'pure' HTML. It is very similar to the earlier example, except that no php is involved in generating the content.

Code: mycustompage.php

define("e_PAGETITLE", "TITLE");

Text, html yada yada


Also, a lot of people like to keep the nice "box" on the top. If you wish to do that just paste the following:

Code: mycustompage.php
+ ----------------------------------------------------------------------------+
|     e107 website system
|     ©Steve Dunstan 2001-2002
|     Released under the terms and conditions of the
|     GNU General Public License (
|     $Source: /cvsroot/e107/e107_0.7/contact.php,v $
|     $Revision: 1.8 $
|     $Date: 2006/08/25 21:03:37 $
|     $Author: e107coders $

Notice the comment on and off chars at the top and bottom: /* and */ If you want to make any comments inside your page but not have them visible when viewing the site you can put your comments in those. (For short comments, which don't extend beyond the end of a line, you can use two slashes: // ).

Also, the $Source, $revision, $Date and $Author entries are updated automatically if you use CVS to manage versions of your code. If you don't, either do not include these lines or update them manually.

Determining who can view the page

The following code can be used to determine who see the page or not. Include immediately after the '$caption=..' line.

Only logged on users

Code: checking for logged on user
if (!USER) {
   $ns->tablerender("Error!", "You must login to view this page");

Only members of a specific userclass

Code: checking for user in a specific userclass
// Define the name of the userclass that CAN visit this page on the next line
// (classes are case sensitive) e.g. $page_class = "Moderator"; 

$page_class = "Moderator"; 
if (!check_class($page_class)) 
   $ns->tablerender("Error!", "You must be part of userclass ".$page_class." to view this page.");

Only Administrators

Code: checking for Admin user
if (!ADMIN) {
   $ns->tablerender("Error!", "Only Admins can view this page.");

See Also