Re: pulling in template file in var and populating vars?

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

 



On Wed, March 22, 2006 3:02 pm, blackwater dev wrote:
> I have a chunk of html data that I want to output for each iteration
> through
> a db result
>
> while($result){
>
>    $list.=file_get_contents("my_template_file.php");
>
> }
> return $list;
>
> The template file looks like this:
>
> <table>
>     <tr>
>          <td><?php echo $result["name"];?></td>
>     </tr>
> </table>
>
> I basically want a good way to keep the template file out of the class
> so I
> don't have to code:
>  $list.="<table><tr>...etc
>
> The problem is with the method I have, it doesn't translate the
> vars...what's the best way to do this?

You have a home-brew templating engine, and you've run into the EXACT
SAME problem every other templating engine has ever had...

So you REALLY ought to look at how Smarty solved it, how PEAR solved
it, how all the other templating engines solved it.

Be Warned:
You're going to go for awhile, and then run into ANOTHER problem which
is the EXACT SAME problem every other PHP Template author has hit.

And you're going to REPEAT this process indefinitely...

Maybe this is a case where re-inventing the wheel is a Bad Idea.

At a minimum, you ought to understand very well how all the other
wheels work, and don't work -- which it is clear from the question
that you don't.

Keep on rollin' :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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