Login   Register  
PHP Classes
elePHPant
Icontem

File: demo_2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of bonvga  >  SmartyX  >  demo_2.php  >  Download  
File: demo_2.php
Role: Example script
Content type: text/plain
Description: demo 2
Class: SmartyX
Extend Smarty to use ModeliXe notation
Author: By
Last change:
Date: 2005-07-08 12:16
Size: 1,901 bytes
 

Contents

Class file image Download
<?php
    
// demo 2 - selective caching

    
$smartyx->smxUseRelativePath(false);
    
    
$smartyx->smxSetTemplate("","demo_bloc.html");
    
$smartyx->smxAssign("color","#FFFF99");
    
$smartyx->smxAssign("title","bloc 1");

    
$smartyx->smxSetTemplate("bloc1","demo_bloc.html");
    
$smartyx->smxAssign("bloc1.color","#99FFFF");
    
$smartyx->smxAssign("bloc1.title","bloc 1.1");
    
    
$smartyx->smxSetTemplate("bloc1.bloc1","demo_bloc.html");
    
$smartyx->smxAssign("bloc1.bloc1.color","#99FF99");
    
$smartyx->smxAssign("bloc1.bloc1.title","bloc 1.1.1");

    
$bloc_cached $smartyx->smxSetTemplate("bloc1.bloc2","demo_bloc.html",10,"bloc1.bloc2");
    if (!
$bloc_cached)
    {
        
// information outwards smartyx 
        
echo "bloc 1.1.2 not cached<br />";
        
        
// emulate "huge" calculation
        
for($i=0;$i<1000000;$i++)
        {
            
$hello "hello";    
        }
        
        
$smartyx->smxAssign("bloc1.bloc2.color","#9999FF");
        
$smartyx->smxAssign("bloc1.bloc2.title","bloc 1.1.2 (cache test)");
    }
    else
    {
        
// information outwards smartyx 
        
echo "bloc 1.1.2 cached<br />";
    }
    
    
$smartyx->smxSetTemplate("bloc1.bloc4","demo_bloc.html");
    
$smartyx->smxAssign("bloc1.bloc4.color","#FF9999");
    
$smartyx->smxAssign("bloc1.bloc4.title","bloc 1.1.3");

    
$smartyx->smxSetTemplate("bloc2","demo_bloc.html");
    
$smartyx->smxAssign("bloc2.color","#FF99FF");
    
$smartyx->smxAssign("bloc2.title","bloc 1.2");

    
$smartyx->smxSetTemplate("bloc2.bloc1","demo_bloc.html");
    
$smartyx->smxAssign("bloc2.bloc1.color","#FF9999");
    
$smartyx->smxAssign("bloc2.bloc1.title","bloc 1.2.1");

    
$smartyx->smxSetTemplate("bloc2.bloc1.bloc1","demo_text.html");
    
$smartyx->smxSetTemplate("bloc1.bloc2.bloc3","demo_text.html");
    
$smartyx->smxSetTemplate("bloc1.bloc3","demo_text.html");
    
$smartyx->smxSetTemplate("bloc1.bloc5","demo_text.html");


    
$smartyx->smxDisplay();

    
/*echo "<pre>";
    print_r($smartyx);
    echo "</pre>";*/
?>