Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 20576 программистов и 984 робота. Сейчас ищет 881 программист ...

$flexy->compile()

Вернуться к: HTML_Template_Flexy

$flexy->compile()

$flexy->compile() – Converts a template from markup to PHP if required

Synopsis

void $flexy-> compile ( string $template )

If necessary it will convert the Template markup into PHP code, and writes it to the compiledTemplate directory adding the {locale}.php to the end of the filename. The Template is only compiled if

  • No compiled file exists

  • The file modification date of the template is greater than the compiled one

  • The forceCompile Flag was set in config or when you created the template object.

It is not normally necessary to set the forceCompile flag, unless you are working on the engine itself.

Parameter

  • string $template - Used in conjuction with the config variable 'templateDir' to locate the template to compile into PHP code.

Return value

string - the location of the compiled file (which could be used with include) - although it is recommended to use the outputObject methods.

In case compileToString option is set to TRUE, the compiled file is directly returned as string here.

Note

This function can not be called statically.

Example

Compiling multiple files.

<?php
class controller_test 
{
    
    var 
$masterTemplate "master.html"
    
var $template "home.html"// name of template
    
var $title;                // page title;
    
var $numbers = array();    // an array example
    
    /* start section - deals with posts, get variables etc.*/

    
function controller_test() 
    {
        
$this->start();
        
$this->output();
    }


    function 
start() 
    {
        
$this->title "<Hello World>";
        
        for (
$i 1;$i5;$i++) {
            
$this->numbers[$i] = "Number $i";
        }
    }
    
    
/* output section - probably best to put this in the default_controller class */
    
    
function output() {
        
$master = new HTML_Template_Flexy();
        
$master->compile('some_file_name');
        
$master->outputObject($this);
    }
    
    function 
outputBody() {
        
$body = new HTML_Template_Flexy();
        
$body->compile($this->template);
        
$body->outputObject($this);
    }
    
    
    
}

new 
controller_test;
?>

Master template example

          Page Header Goes here.   {outputBody()}   Page Footer Goes here

Simple ouput example

                 Page Header Goes here.   some numbers Number 1 Number 2 Number 3 Number 4   Page Footer Goes here


Вернуться к: HTML_Template_Flexy

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware