Re: [Nolug] PHP help

From: Petri Laihonen <pietu_at_weblizards.net>
Date: Fri, 18 Apr 2008 11:18:44 -0500
Message-ID: <4808C9E4.1070301@weblizards.net>

To clarify, I understand templating system as separating the main PHP
code from the design.
Simplest "templating" system I have seen done with PHP goes along
these lines.

Designer makes their web pages with "tags" and save as myfile.html

in PHP one just does
$original_file = get_file_contents('myfile.html');
$new_file = str_replace("tag1",$whatever_var,$original_file);
echo $new_file;

Often the replacement arrays work nicely.
str_replace($repl_arry,$repl_with_arry,$original_file);

I still have some websites (designed by 2 fine German "space" engineers)
which use completely custom made templating system and additionally the
site construction is extremely complex. (Ridiculously complex and then
some) Even after several years, I still do not know how to make some
desired changes in the site to work on all pages. Also, how to make a
working link from a banner on the site to go to specified content
category within the site. It is going to be the day of joy when I have
time to redo the entire site with a lot simpler PHP + smarty as
template. Same PHP code will work for both mobile and desktop browsing.

Petri

Jess Planck wrote:
> HA! Joey had throw PERL!
>
> Here's a simple example:
>
> /// put in file include.php
> <?php
> function spiffy_html( $text = '' ) {
> echo '<p class="nobody" id="nothing">';
> echo $text;
> echo '</p>';
> }
> ?>
>
> // put in file application.php
> <?php include( 'include.php' ); ?>
> <html>
> <body>
> <?php spiffy_html(); ?>
> </body>
> </html>
>
> So right there you have separated SOME of your HTML/UI with your php
> code. This example is very short, so it can be done a heck of a lot
> better. The thing is in many cases you can get further thinking about
> PHP as a template system itself. It can reduce complexity since in
> most cases with Smarty and Flexy you will be working with the PHP API
> and then working with an additional Template System API that is
> typically not interchangeable. If you are thinking about template
> systems because of caching features then in the above case you should
> be looking toward memcache and others.
>
> Also always remember just because you use "include( blah.php )"
> doesn't mean that blah.php has to have any real PHP code. It could be
> "include( blah.html )" for just sticking in HTML stuff.
>
> For Petri..
>
> Smarty Code: {function_name name1="some value" name2="some other value"}
>
> is really no more difficult to understand than
>
> PHP Code: <?php function_name( 'some value', 'some other value' ) ?>
>
> I think Joomla, Drupal and WordPress follow the PHP as template engine
> system, so you can look to those complex applications for inspiration.
>
> Jess
>
> [ :P ] jess planck - http://funroe.net
>
> On Apr 18, 2008, at 9:22 AM, Joey Kelly wrote:
>> Pipeline vs. callback:
>> http://www.perl.com/pub/a/2001/08/21/templating.html
>
> ___________________
> Nolug mailing list
> nolug@nolug.org
>
___________________
Nolug mailing list
nolug@nolug.org
Received on 04/18/08

This archive was generated by hypermail 2.2.0 : 12/19/08 EST