Hi gang, I am having a problem with how I should go about templates. I am not sure if my approach is a very good one considering its disadvanatges, so please have a look.

here we go, the way I do it now. In order to require as little php knowledge as possible from the designer I even factor out very little template bits into their own files.

Have a look at this code:

PHP Code:
<?php
    
private function issueArchive() {  
        
// fetch the issues from the collection and build
        // html with them
        
$rows=array();

        while ( 
$issue=$this->issueCollection->fetch() ) {            
            
$issueRow =& new Template('issue_row'); 
            
$issueRow->setValue('{DATE}',date('F d, Y'$issue->getDate() ));
            
$issueRow->setValue('{ID}',$issue->getId());
            
$issueRow->parse();            
            
$rows[] = $issueRow->fetch();
        }
               
        
// Alternating Row Color Support
        
require_once(VIEW_HELPER_PATH.'AlternatingRowColorer.php');
        
$rowColorer=& new AlternatingRowColorer($rows'{ROW_COLOR_CLASS}''row1''row2');
        
$rows=$rowColorer->fetch(); 
        
        
// convert the rows to a string
        
require_once(VIEW_HELPER_PATH.'ArrayToStringConverter.php');
        
$conv=& new ArrayToStringConverter($rows);
        
$rows=$conv->fetch(); 
        
        
// acquire heading, etc - build the page
        
if(count($rows) > 0) {
            
// Get heading
            
$heading =& new Template('issue_list_heading');
            
$heading->setValue('{TEXT}','Community Crier Archive');
            
$heading->parse();
            
$heading $heading->fetch();
            
            
$archive =& new Template('issue_list');           
            
$archive->setValue('{TITLE}',$heading);
            
$archive->setValue('{ROWS}',$rows);
        } else {
            
$archive =& new Template('error_page');
            
$archive->setValue('{TITLE}','Error Title');
            
$archive->setValue('{CONTENT}','Sorry, there are no issues yet!');
        }
        
        
$archive->parse();
        return 
$archive->fetch();
    }
}
?>
Should be self-explaining, if not, please ask.

This is what the issue_row template file includes:

Code:
<li>Issue from <a href="index.php?page=view_issue&amp;id={ID}">{DATE}</a></li>
This is what the template file 'issue_list' includes:

Code:
{TITLE}
<ul class="archive_list">
{ROWS}
</ul>
Okay what does that tell us? The presentation is greatly outsourced into files. The designers won't have to deal with any php code or code of another scripting language (other than Javascript if they want to use it - the php coder doesn't care).

Problem: He has to mess with HUNDREDS of files. Basically whenever I use a list of things I create a separate ****_list file template, that contains '<li>{VAR]</li>' or something. Now that is not very cool. The question is how can I mainatain all this decoupling while storing more template information in the different files? Sounds like using functions, but then again this would mean adding php code to the scripts. Any ideas here?