Create a standalone Custom Page
e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page
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
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
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:
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.
Also, a lot of people like to keep the nice "box" on the top. If you wish to do that just paste the following:
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: // ).
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
Only members of a specific userclass