As for templating, I usually use a View class that receives variables
and values from a controller of sorts, the when the controller is
ready to render it calls the view objects render() method which starts
the output buffer, extracts all the set vars, requires the template
then returns the output buffer (the parsed template) to the
controller.
> --
> This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
>
> For information or project assistance please visit :
> http://www.360psg.com
>
> You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
> To post to this group, send email to Professi...@googlegroups.com
> To unsubscribe from this group, send email to Professional-P...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/Professional-PHP
I prefer using this. Parent is equally good too
<robert.anthony.gonza...@gmail.com> wrote:
> Using parent:: calls are totally acceptable, but if you...
> On Sunday, August 29, 2010, nickW+ <n...@weeklyplus.com> wrote:
> > Hello All,
>
> > So i'm curiou...
> > For more options, visit this group athttp://groups.google.com/group/Professional-PHP
>
>
--
This group is managed and maintained by the development staff at 360 PSG. An enterprise app...
Np at all
On Aug 30, 2010 12:48 AM, "nickW+" <ni...@weeklyplus.com> wrote:> I prefer using this. Parent is equally good too
I use this for all my within class declarations, I never tried to do
it for the parent.
For consistency this will certainly make my code much more uniform as
the parent:: stuck out like a sore thumb.
I figured there was some way to do it with an object just didn't
imagine it would be that, I feel dumb now lol.
Thanks again.
On Aug 29, 10:26 pm, Subir Jolly <subirjo...@gmail.com> wrote:
>
> On Aug 30, 2010 12:21 AM, "nickW+" <n...@weeklyplus.com> wrote:
>
> Hey thanks for the reply Ro...
This group is managed and maintained by the development staff at 360 PSG. An enterprise application ...
If I understand your explanation right, you're on the right track.
> I understand the View class, object all that but how do you replace
> the variables in the buffer? Do you use str_replace or another method?
All of this assumes you're managing data output correctly, so by the
time you get here, there's no headers, etc that needed to be sent.
(Maybe cookies).
- While your script runs, set up the variables to give to the view
and place it somewhere in an array.
- Call the special function to import the view
- Extract the variables
- Turn on output buffering
- Include the template file
- Use ob_get_clean or ob_get_contents to store the newly parsed include
- You're on your way.
>
> Basically here are the two ways i'm thinking:
>
> Version 1:
>
> function results_template(){
> return '<div id="go">{silly_var}</div>';
> }
>
> function replace_template_tags(){
> $tags['{silly_var}'] = 'Hello World';
>
> $search = array_keys($tags);
> $replace = array_values($tags);
>
> $template = $this->results_template();
>
> $template = str_replace($search, $replace, $template);
> }
>
> Version 2:
>
> function results_template($tags){
> return '<div id="go">'.$tags['silly_var'].'</div>';
> }
>
> function replace_template_tags(){
> $tags['silly_var'] = 'Hello World';
> $template = $this->results_template($tags);
> }
>
> Both results_template functions use an extremely simply html return
> for example only. The version I have implements ob_start, etc.
--
Jack Timmons
@_Codeacula
click here for more info http://www.source-code.biz/MiniTemplator/
the point is this: I want to separate the PHP code FROM the HTML code as
much as possible. the only way I found is to have this php class read a
html template and output a string according to my instructions.
so, in any case. in html you will only want to write-in variables and
make loops, right? right. so you can make your coding in html, read a
html template, then output everything into a variable or you can also
write it on a file.
And the final question is this: did anyone ever worked with php
templates? and only if you did, please reply me with what template
engines you have been working with. thank's a lot. no, really... thanks.
Cheers!