working on a template system...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi, i'm working on a template system. Basically i'm building raw
contents in arrays and then put them in templates by some special
tags.

for loop systems my basic array structure is like this:
$array['key'][]['keyword'] = ...

for example, for a bulletin board system, array structure for
categories is something like this:
$array['categories'][]['text_category_name'] = ...

it is looped through database recordset, so final array for 2 categories can be:
$array['categories'][0]['text_category_name'] = 'programming'
$array['categories'][1]['text_category_name'] = 'life'

template file structure for loops is something like this (ex, categories):
<!-- loop|categories:bof -->
<tr>
  <td>[$text_category_name$]</td>
</tr>
<!-- loop|categories:eof -->

i can easily loop this template and replace [$text_category_name] for
every category set in the array. after removing the comment tags i get
the final content:

<tr>
  <td>programming</td>
</tr>
<tr>
  <td>life</td>
</tr>

But i'm stuck with nested loops. For example i want to put related
forums after each categories.

array structure is:
$array['categories'][0]['text_category_name'] = programming
$array['categories'][0]['forums'][0]['text_forum_name'] = php
$array['categories'][0]['forums'][1]['text_forum_name'] = ruby

$array['categories'][1]['text_category_name'] = life
$array['categories'][1]['forums'][0]['text_forum_name'] = music
$array['categories'][1]['forums'][1]['text_forum_name'] = sports

template structure is:
<!-- loop|categories:bof -->
<tr>
  <td>[$text_category_name$]</td>
</tr>
<!-- loop|forums:bof -->
<tr>
  <td>[$text_forum_name$]</td>
</tr>
<!-- loop|forums:eof -->
<!-- loop|categories:eof -->

i've written some functions, used them recursively but it didn't work.
actually i couldn't find the true logic. note that it isn't a limited
array. it can have messages under each forums, peoples under each
messages, so on..

help me find the true approach to handle this. thank you.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux