Thule - 0.9.6
  • Welcome
  • Introduction
  • - MVC(Model-View-Controller)
    - Architecture of Framework
    - Flow Chart of Application
    - Services In One Server
    - Developing Guide
    - Features
  • Installation
  • Getting Started
  • - Direct Access HTTP
    - Router Access HTTP
    - Router Direct Access HTTP
    - Reserved Function
    - Convention
    - Bootstrap
    - Pack Javascript , CSS
  • Basic Modules
  • - Model
    - View
    - Controller
  • Libraries
  • - Router
    - Config
    - Response
    - Request
    - Database
    - Query
    - Cache
    - Debug
    - Log
    - Unit Test
    - Registry
    - Profile
  • Helper
  • - Auth
    - Calendar
    - Date
    - Error page
    - Email
    - Form
    - GeoIP
    - Google
    - Html Element
    - Html
    - Http
    - I18n
    - Image
    - Json
    - Jquery
    - Login
    - Layout
    - Locale
    - PHP to Javascript
    - Paging
    - Payflow
    - Soap
    - Text
    - Table
    - Uri
    - Upload
    - Validation
  • Plugins
  • - Smarty Template Engine
  • History
  • Home >Table

    Table helper is very useful and powerful helper. you can make the table from database automatically as just input some format to table array.

    Load Table Helper

    $FE->loadHelper("table");

    Make the array of table

    first inside array is tr-tag and inside the tr-array is td-array

        "table"=> array(
            array( // this array is "tr"
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            ),
            array(
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            )
        );

    Make content-data in td-array

        "table"=> array(
            array( // this array is "tr"
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            ),
            array(
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            )
        );

    How to put the html tag to content-data in td-array

        "table"=> array(
            array( // this array is "tr"
                array("cdata"=>array(
                array("div"=>array("id"=>"bbb","cdata"=>"1111")),
                array("cdata"=>" "),
                array("div"=>array("style"=>"clear:both;")),
                array("input"=>array("id"=>"aaa","value"=>"2222")),
            )"
    ,"id"=>"aa","class"=>"asdfas"),
            ),
            array(
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            )
        );

    Make the attribute array of table

    If the tr-array's element is not array type,it will be attributes.

        "table"=> array(
            array( // this array is "tr"
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            "id"=>"table1","class"=>"tbclass",
            ),
            array(
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            )
        );

    Make the header-array of table

    If the tr-array's element is not array type,it will be attributes.

        "table"=> array(
        "header"=>array(
            array(
                array("cdata"=>"Name"),
                "id"=>"1",
            ),
            "id"=>"1", // attribute of thead
            )
    ,
            array( // this array is "tr"
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
                "id"=>"table1","class"=>"tbclass",
            ),
            array(
                array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            )
        );

    Make the total array of table

    $table=array(
        "header"=>array(
            array(
                array("cdata"=>"Name"),
                array("cdata"=>"Address"),
                array("cdata"=>"Calendar"),
                array("cdata"=>"Profile"),
                "id"=>"1",
            ),
            "id"=>"1",
        ),
        array(
            array("cdata"=>"<input type='text' value='text'/>","id"=>"aa","class"=>"asdfas"),
            array("cdata"=>"asdfsdfasdf","id"=>"aa","class"=>"asdfas"),
            array("cdata"=>"asdfasddddddf","id"=>"aa","class"=>"asdfas"),
            array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
            "id"=>"1",
        ),
        array(
            array("cdata"=>array("input"=>array("id"=>"aaa","value"=>"fff")),"id"=>"aa","class"=>"asdfas"),
            array("cdata"=>array(
                array("div"=>array("id"=>"bbb","cdata"=>"1111")),
                array("cdata"=>" "),
                array("div"=>array("style"=>"clear:both;")),
                array("input"=>array("id"=>"aaa","value"=>"2222")),
            ),
                "id"=>"aa","class"=>"asdfas"),

                array("cdata"=>array(
                array("a"=>array("href"=>"bbb","cdata"=>"link")),
                array("cdata"=>" "),
                array("input"=>array("id"=>"aaa","value"=>"2222")),
                ),"id"=>"aa","class"=>"asdfas"),
            array("cdata"=>"asdfabbbbbb","id"=>"aa","class"=>"asdfas"),
            "table"=>array(
                array(
                    array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
                ),
                array(
                    array("cdata"=>"asdfasdf","id"=>"aa","class"=>"asdfas"),
                ),
                ),
                "id"=>"2",
        ),
        "class"=>"asddfas",
        "id"=>"asdfasdf",
        "style"=>"width:800px;",

    );

    Generate the table from database

    $Frontend->members is from database which is created by model or controller.

    $table=$Frontend->Table->genTable($format,$Frontend->members);
    echo $Frontend->Table->draw($table); // display the table

    Make the format of table and generate the table from database

    you can generate the table from database very simply as making the format of table such as header and each columns.

    $format=array(
        "header"=>array(
            array(
            array("cdata"=>"id"),
            array("cdata"=>"NickName"),
            array("cdata"=>"email"),
            array("cdata"=>"level"),
            ),
        ),
        "columns"=>array('$member_id',
            '$member_nickname',
            '$member_email',
            '<input type=\"text\" value=\"$member_level_id\">'),
        "class"=>"table",
        "id"=>"asdfasdf",
        "style"=>"width:800px;",
        );
    $table=$Frontend->Table->genTable($format,$Frontend->members);
    echo $Frontend->Table->draw($table);