[PHP] Processing PHP in Template File

2002-09-12 Thread [-^-!-%-


Hello everyone.

I want to implement templates in a site, but am having trouble processing
php within the template file. The application flow is as follow:

-open the template file (which has some place holders) with
$fileHandler =  file($file_name)

-Replace placeholders (within the template files) with
 $fileHandler = ereg_replace(--PlaceHolder--,New content,$Handler)
 //disregard syntax errors...

-Then display the content of the modified template
 $fileHandler = implode('',$fileHandler)
 echo $fileHandler;


The above process works, as far as replace the place holders, and printing
the new content (which is an HTML file). However, it will not process PHP
scripts, within the template.

For example, if my template has

html
 ..
body

   ?php
 echo hello!;
   ?
pblah blah blah
/body
/html

the above process will display the PHP code within the HTML file, without
processing.

How can I process the PHP codes that's in the template?


-john



=P e p i e  D e s i g n s
 www.pepiedesigns.com
 Providing Solutions That Increase Productivity

 Web Developement. Database. Hosting. Multimedia.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Processing PHP in Template File

2002-09-12 Thread Chris Boget

 The above process works, as far as replace the place holders, and printing
 the new content (which is an HTML file). However, it will not process PHP
 scripts, within the template.

If it's really a template, why does it have PHP scripts within?  Why not just
replace those scripts with place holders and process as you would normally?

Chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Processing PHP in Template File

2002-09-12 Thread Support @ Fourthrealm.com

John

Include your template this way:

$file_name=templates/somefile.php
$New_Content1 = 'This is the new text';
$New_Content2 = 'This is the other text';
include $file_name;


In the template file, have ?php echo $New_Content; ? etc wherever the 
content should appear.

Then you can put other php code in the template file as well.

I use this all the time.


Peter


At 12:00 PM 9/12/2002 -0700, you wrote:

Hello everyone.

I want to implement templates in a site, but am having trouble processing
php within the template file. The application flow is as follow:

-open the template file (which has some place holders) with
$fileHandler =  file($file_name)

-Replace placeholders (within the template files) with
  $fileHandler = ereg_replace(--PlaceHolder--,New content,$Handler)
  //disregard syntax errors...

-Then display the content of the modified template
  $fileHandler = implode('',$fileHandler)
  echo $fileHandler;


The above process works, as far as replace the place holders, and printing
the new content (which is an HTML file). However, it will not process PHP
scripts, within the template.

For example, if my template has

.. ?php echo hello!; ?

blah blah blah
the above process will display the PHP code within the HTML file, without
processing.

How can I process the PHP codes that's in the template?


-john



=P e p i e  D e s i g n s
  www.pepiedesigns.com
  Providing Solutions That Increase Productivity

  Web Developement. Database. Hosting. Multimedia.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

- - - - - - - - - - - - - - - - - - - - -
Fourth Realm Solutions
[EMAIL PROTECTED]
http://www.fourthrealm.com
Tel: 519-739-1652
- - - - - - - - - - - - - - - - - - - - -


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Processing PHP in Template File

2002-09-12 Thread [-^-!-%-


You are absolutly correct.
Thx!


=P e p i e  D e s i g n s
 www.pepiedesigns.com
 Providing Solutions That Increase Productivity

 Web Developement. Database. Hosting. Multimedia.

On Thu, 12 Sep 2002, Chris Boget wrote:

  The above process works, as far as replace the place holders, and printing
  the new content (which is an HTML file). However, it will not process PHP
  scripts, within the template.

 If it's really a template, why does it have PHP scripts within?  Why not just
 replace those scripts with place holders and process as you would normally?

 Chris



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php