Location: PHPKode > scripts > Block template > block-template/btsample.php
<?php
/** 
basic Sample of use for block_template 
templates are in ./template directory
*/

# include the class file
include_once('libs/class-block_template.php');

$page_title     = 'TEST PAGE';
$template_name  = 'default';

# instantiate template parser, doing this the file template/default/template.php will be read 
# and if a template/default/css.css exist then it will be automaticaly added
$page = &new block_template($page_title,$template_name);

# you can add an alternate stylesheet like this
$page->add_css('path_to_alternate_css.css','csstitle',TRUE);
# or add css rules in the header (<style></style>) like this
$page->add_css('a:hover {color:red;}');
$page->add_css('
  .header {color:red;font-size:24px;text-lign:center;}
  .menu {float:left;background:silver;color:navy;}
  .box  {border:solid silver 1px;display:table;margin:15px;}
  .title{position:relative;TOP:-20px;border:dashed silver 1px;background:white;display:table;padding:0 10px 0 10px;font-size:16px;}
');
# you can add javascript file or function in the same ways using add_js() method
$page->add_js("path_to_javascript_file.js");
# or even a favicon by using add_favicon.
$page->add_favicon('path_to_favicon.ico');
# If you want you can add some meta
$page->add_meta("page description",'description');

# Now the interesting stuff:
#create a menu:
for($i=0;$i<5;$i++)
  $menuentrys .= $page->templatize(array('url'=>'bttest.php','label'=>"menu entry $i"),'MENU_ENTRY');
$menu = $page->add_templatize_content(array('menuentrys'=>$menuentrys),'MENU');

# now add some boxed content (see related method for more details)
$page->add_box_content('here your box content','box title');

# add some news
for($i=0;$i<5;$i++)
  $news .= $page->templatize(array('url'=>'bttest.php','intro'=>"intro for news $i, just an intro at all!",'title'=>"$i title"),'NEWS_INTROS');
$news = $page->templatize(array('newscontent'=>$news),'NEWS_BOX');
$page->add_content($news);

# and then render the page (you can save it to a file and manage a cache if you want)
$page->output(array('title'=>'Block Template TEST PAGE'));



?>
Return current item: Block template