anishmm / render

该包最新版本(dev-master)没有提供许可信息。

链接、表格、页面渲染器

dev-master 2017-06-02 05:47 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:02:24 UTC


README

创建类型为链接、表格、基本页面(含标题、正文和标签等)的渲染器。

渲染数组示例

表格渲染数组示例

$table = array(
    'type' => 'table',
    
    // list of table headers
    // an array of strings
    'headers' => array(
        'col_name_1',
        'col_name_2',
        'col_name_3',
        ...
    ),
    
    // an array of arrays representing rows
    // render arrays for tables or links
    'rows' => array(
        
        // a row may be array of strings
        array(
            'row_1_cell_1',
            'row_1_cell_2',
            ...
        ),
        
        // a row may be array of render arrays for links and tables
        array(
            $render_array_for_link,
            $render_array_for_table,
            ...
        ),
        
        // a row may be an array of both render arrays and strings 
        array(
            $render_array_for_link,
            'row_2_cell_2',
            $render_array_for_table,
            ...
        ),
        ...
    ),
);

说明

对于表格,列数取自表头数量,如果一行包含多于单元格值的数量,则丢弃末尾的额外值。

链接渲染数组示例

$link = array(
    'type' => 'link',
    
    //string containing the url to be linked
    'url' => $url_to_my_page,
    
    //string containing the link text
    'text' => $link_text,
);

说明

默认链接文本为“点击此处”。

页面渲染数组示例

$page = array(
    'type' => 'page',
    
    //string containing title of page
    'title' => $title_for_my_page,
    
    //string OR render array for link or table OR
    // array of strings and render arrays for links and tables
    'body' => array(
        $render_array_for_table,
        $render_array_for_link,
        "this is an example",
        ...
    ),
    
    //array of link render arrays
    'tags' => array(
        $tag_1_link,
        $tag_2_link,
        $tag_3_link,
        ...
    ),
);

说明

页面标签是可选的。