Saturday, July 30, 2011

Slot Helper

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>

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

Friday, July 9, 2010

Tuesday, July 7, 2009

codeilo_v1beta4.1.zip bugfix

-bug fix for ajax
-bug fix for select box options

download

Monday, July 6, 2009

version 1 beta 4 (support both ajax and no ajax)

- additional assets file.
- all put into ci application's web folder.

codeilo_v1beta4.zip
Download

Wednesday, July 1, 2009

support ajax

codeilo v1 beta 3

- codeigniter ajax crud mvc template.

http://www.box.net/shared/e0h5pif4eg

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