Re: [PHP3] Re: [PHP Template] Re: [PHP3] Re: [PHP Template] Template Discussion

[email protected] ("John Coggeshall") Wed, 22 Mar 2000 16:15:23 -0500
Newsgroups php.template
Message-ID <[email protected]>
>On Wed, 22 Mar 2000, John Coggeshall wrote:
>> How about this...
>> 
>> backend.php3
>> -=-=-=-=-=-=-=-
>> function loop($arrayvar) {
>> 
>>       for($loop = 0; $loop <= count($arrayvar); $loop++) {
>>         
>>            echo $arrayvar[$loop];
>>            echo $arrayvar[$loop];
>>            echo $arrayvar[$loop];
>> 
>>    }
>> 
>> }
>> -=-=-=-=-=-=-=-
>> EOF backend.php3
>> 
>> Then your "template"....
>> 
>> <? loop($Name); ?>
>> 
>> 
>> Now I'm definately not a designer... but boy that looks simple to me.



>I don't think that's going to be of much use. What if the designer wants
>to put each loop iteration in a table row? Alternate the background
>colors on each row? Bold it? Italicize it? You would have to modify
>backend.php3 - and lose the separation of form and content.


Okay about about this then:

<?php function loop($preHTML, $var, $postHTML) {

            echo $preHTML;

            if(is_array($var)) {

                    for($l = 0; $l <= count($var); $l++) {

                        echo $var[$l];
                    
                    }

            } else {

                echo $var;

            } 

            echo $postHTML;

}


Then in your file

<? loop("<TD BGCOLOR=#FFFFFF ALIGN=LEFT><B>", $var, "</B></TD>"); ?>

No syntax changes needed.

John