CodeIgniter模板分析器变量数组?

时间:2013-06-18 08:04:00

标签: php codeigniter parsing templates

因此,我的传统方法是使用模板解析器类而不是标准视图加载方法。唯一的问题是,如果使用多个category变量,变量可能会在一段时间后开始变得混乱。

例如......像这样的数组:

$data = array(
    'THREAD' => array(
        'TITLE' => "Some Cool Title",
        'MESSAGE' => "Hello, world!",
        'AUTHOR' => $author_info //Some Array of author's info
    ),
    'COMMENT_RESULTS' => array(
        array(
            'MESSAGE' => "hello, world!",
            'AUTHOR' => array()
        )
    )
);

查看:

<h1>{THREAD:TITLE}</h1> 
<H2>Posted by {THREAD:AUTHOR:USERNAME}

<p>{THREAD:MESSAGE}</p>

<ul>{COMMENT_RESULTS}
     <li>
          {COMMENT:MESSAGE}
          Posted by {COMMENT:AUTHOR:USERNAME}
     </li>
</ul>

1 个答案:

答案 0 :(得分:1)

{TITLE}

Posted by {AUTHOR}

{MESSAGE}

{COMMENT_RESULTS}

      {MESSAGE}
      Posted by {AUTHOR}

{/COMMENT_RESULTS}