Re: can I sandwich html docs with PHP
| From: | Peter J. Schoenster | Date: | Tue, 12 Feb 2002 05:07:32 +0000 |
| Subject: | Re: can I sandwich html docs with PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84358@lists.php.net to get a copy of this message | ||
On 11 Feb 2002, at 19:30, Michael Sims wrote:
> I'm not sure I really know what you're asking, but if you are asking
> if you can use PHP code within HTML files (with *.html extensions)
> then the answer is yes. If you're running Apache, add the following
> to your httpd.conf:
> Please disregard if this is not what you were asking... :)
No, thanks. It tells me I wasn't clear.
Using mod_perl I can write a module for any phase that Apache
goes through while handling a request. Based upon any variables I
want, I can tell Apache to have my module handle one of those
phases. So when you request this url for example:
http://www.mydomain.com/joe.html
My module can take joe.html and insert it as the body of a
template and then return that to your browser or if you request
something else like
http://www.mydomain.com/image_of_joe.gif
then my module just declines to handle that and apache continues
through it's phases.
Here is an example (bad execution of an example though)
http://161.58.230.66/images/
I have the following .htaccess file in that directory:
SetHandler perl-script
PerlHandler Apache::Schoenster_Gallery
PerlSetVar DOCROOT /usr/local/etc/httpd/htdocs/images
PerlSetVar URL_PATH /images
I can stick this .htaccess file in any directory (only makes sense
where I have images) and it uses those 2 variables above to
determine where to read for images and where to write the files
which produces the frame-set that you see (the module looks in
that file for templates to parse so I can have different looks in
different places wihout changing the module). I say it's a bad
execution because I'm using imagemagick to resize (regardless of
original size). If I add new images it will automatically create a
thumbnail (which can currently be larger than the original :) of that.
I use a db file to cache thumbnails already created but it does
check file modification date to see if it should resize the image or
not.
But what I want to do is to do this with html files where I'll have a
few templates (header,footer,navigation,boxes) that will be created
on the fly depending upon variables when a client requests an html
file and I want to know if I can do this in PHP without rewriting the
url (which is not such a bad option perhaps).
Peter
---------------------------
"Reality is that which, when you stop believing in it, doesn't go
away".
-- Philip K. Dick