Introduction
Symfony Slot like function.
http://www.symfony-project.org/book/1_0/07-Inside-the-View-Layer#chapter_07_sub_slots
Require library
http://codeigniter.com/wiki/layout_library/
Source
helpers/slot_helper.php
<?php
function slot($name){
Slot::setName($name);
ob_start();
}
function end_slot(){
$name=Slot::getName();
Slot::set($name,ob_get_contents());
ob_end_clean();
}
function get_slot($name,$default=''){
return ( Slot::get($name)==false )?$default:Slot::get($name);
}
class Slot{
static $name='';
static $content=array();
static function setName($in){
self::$name=$in;
}
static function getName(){
return self::$name;
}
static function set($key,$val){
self::$content[$key].=$val;
}
static function get($key){
if( !isset(self::$content[$key]) ){
return false;
}
return self::$content[$key];
}
}
?>
Usage
template.php
<html >
<head>
<title><?php echo get_slot('html_title',''); ?></title>
<?php echo get_slot('html_head',''); ?>
</head>
<body>
<?php echo get_slot('html_body',''); ?>
</body>
</html>
view_file.php
<?php slot('html_title'); ?>
I am page title.
<?php end_slot(); ?>
<?php slot('html_head'); ?>
<!-- Hi! This content will be show inside head tag. -->
<script type=\"text/javascript" src="../nav/nav.js"></script>
<?php end_slot(); ?>
<?php slot('html_body'); ?>
Hi! This content will be show inside body tag.
<?php end_slot(); ?>
Output
<html >
<head>
<title>
I am page title.
</title>
<!-- Hi! This content will be show inside head tag. -->
<script type=\"text/javascript" src="../nav/nav.js"></script>
</head>
<body>
Hi! This content will be show inside body tag.
</body>
</html>
Saturday, July 30, 2011
Tuesday, July 27, 2010
codeilo_v1beta4.3.zip
- bug fixed. Auto gen select field for Multi Foreign Key
- new feature. schema file.
additional argument schemaonly
"php generator.php schemaonly"
user can edit schema( e.g. foreign key setting) before generate program code.
download
- new feature. schema file.
additional argument schemaonly
"php generator.php schemaonly"
user can edit schema( e.g. foreign key setting) before generate program code.
download
Friday, July 9, 2010
Tuesday, July 7, 2009
Monday, July 6, 2009
Wednesday, July 1, 2009
Friday, June 26, 2009
enhanced CI pagination
(For codeigniter v1.7.1)
Additional parameter for pager assign href value and onclick function.
{arg} value will be replace by {paging link tag}.
so that if paging link tag is 20.
ci class will output: href="http://sample/page/20"
this class will output: href="http://sample/page/20" onclick="doSomething('20'); return false;"
[sample]
$pagination_config['base_function_name'] = jhistoryList(\'#list/format/html/begin/{arg}\')';
$pagination_config['replace_href_content'] = current_url().'#list/format/html/begin/{arg}';
$this->pagination->initialize($pagination_config);
Download
Additional parameter for pager assign href value and onclick function.
{arg} value will be replace by {paging link tag}.
so that if paging link tag is 20.
ci class will output: href="http://sample/page/20"
this class will output: href="http://sample/page/20" onclick="doSomething('20'); return false;"
[sample]
$pagination_config['base_function_name'] = jhistoryList(\'#list/format/html/begin/{arg}\')';
$pagination_config['replace_href_content'] = current_url().'#list/format/html/begin/{arg}';
$this->pagination->initialize($pagination_config);
Download
Subscribe to:
Posts (Atom)