PHP Classes
Icontem

File: btsample.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of jonathan gotti  >  Block template  >  btsample.php  
File: btsample.php
Role: Example script
Content type: text/plain
Description: sample of use
Class: Block template
Template engine based in the concept of blocks
 

Contents

Class file image Download
<?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'));



?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products