eXtension Templates for PHP (XTP for short)

Logic behind templates - PHP

As we already saw every but the most trivial components need to have class behind it in order to be able to better control its behavior. We will again illustrate how this all works with simple example -- navigation.php file corresponding to before mentioned navigation.phpx file:

<?php
class Navigation extends WebControlX {

    public $Menu;

    public function PreRender() {
        if (self::$Session['user']) {
            $this->Menu = '<ul>
                <li><a href="/phpx/index.php">Your Tickets</a></li>
                <li><a href="/phpx/index.php?change_data=-7">Account Data</a></li>
                <li><a href="/phpx/index.php?logout=c6h8">Logout</a></li>
            </ul>';
        }
        elseif (self::$Session['admin']) {
            $this->Menu = '<ul>
                <li><a href="/phpx/index.php?logout=c6h8">Logout</a></li>
            </ul>';
        }
    }
}
?>

Looking this simple example we can notice few important things:

« Previous
Sample component - HTML
Next »
Starting XTP engine