-
Notifications
You must be signed in to change notification settings - Fork 1
Create_a_standalone_Custom_Page
Custom pages and menus are normally stored in the database, and given names such as:
yoursite.com/page.php?3
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.
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.
If you want to use the standard shortcodes in your file, replace the line:
$text = $tp->toHtml($text);
with:
$text = $tp->toHtml($text, TRUE, 'parse_sc, constants');
(There are other options; refer to documentation on the $tp->toHtml() function for further information).
Once created, you can specify links to the page in the normal way; for example:
{e_BASE}mycustompage.php
Or add a link in admin>>sitelinks
If you want to use an image that is saved in your theme images folder use
{THEME}images/YOURIMAGE.gif
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.
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: // ).
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.
The following code can be used to determine who see the page or not. Include immediately after the '$caption=..' line.
- HowTo Show News In Index.php Following this logic, you should be able to see how other page content can be included in another.