Creating a CodeBehind Page


To create a CodeBehind page, simply create a new .php file in your site/control directory. Name the file as you would like to reach it from your web browser. Note that you can reach your created CodeBehind page with our without its extension.

For example, if you create a file: site/control/hello.php, you could reach it in your browser at: http://www.yoursite.com/hello

Also note that you can name your CodeBehind file index.php and place it inside another folder. For example: site/control/hello/index.php. This same page could be reached at: http://www.yoursite.com/hello

Inside your created CodeBehind page you have access to all globals, utility classes, and features of the TextSide engine.

From here you have two choices in creating your page: you can either treat it like a regular PHP page and enter your RAW php, or you can implement a Page class within the file. Creating a Page class gives you access to additional features and allows your CodeBehind page to automattically fit in with the theme of your site. It also allows you to mix your CodeBehind static content with the reusable parts.

Raw PHP CodeBehind Pages


Raw PHP CodeBehind pages are exactly like regular PHP pages, except they are served using the TextSide Engine and have access to extra utilities and globals.

Simply add any PHP code in the file that you wish. For example:

<?php 
global $siteUser;
echo(
"Hello $siteUser->name");
?>
This would be rendered as:
plain.jpg

Class CodeBehind Pages


CodeBehind files that implement a Page Class are able to offer more features than regular PHP files. They allow your content to fit seamlessly in with the rest of your sites theme and even co-exist with parts placed on a page. Usually creating a page class is the perferred method of creating a Code Behind page.

To create a page class, simply create a new class that extends from page. In the new class, create a method named: area1(), area2(), or area3() depending on where you would like your content displayed on the page. Area1 is usually the left hand side, Area2 is the center page, and Area3 is the right hand side. (where an area is rendered is based on the layout that your page is using - see Themes for more information).

Example:


<?php
/*===========================================================
CodeBehind Page
Hello World sample page
============================================================*/
class pageHello extends page {
    var 
$layout "Columns1"//optional - name of layout file in Theme directory
    /*===========================================================
    AREA 2 - Center Page Content
    ============================================================*/
    
function area2(){
        
$this->title "Sample CodeBehindPage";
        global 
$siteUser;
        return 
"Hello $siteUser->username";
    }
}
?>
This page would be rendered as:
class.jpg
You can see that, even with very little code, this allows you to integrate your code with the rest of your sites layout.

The rest of the documentation on CodeBehind pages will largely revolve around Clase CodeBehind pages.