httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Billy Bacon <bi...@billybacon.com>
Subject Re: [users@httpd] using php in header file
Date Tue, 27 Apr 2004 13:32:12 GMT
I tried the suggestion below but didn't get the result I was hoping for :-(

I see this in the 'View Source' when I execute the page through a browser...

---------------------- snippet --------------------------
<?php
    include_once $_SERVER['DOCUMENT_ROOT'].'/includes/layout.php';
    cfheader("");
?>
<html>
<head>
.....
---------------------- snippet --------------------------


Here's what I did... I added a .htaccess file to the directory where this
.htm template resides and put the following lines in it:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Then I added the above PHP code into the .htm file (see above). But when I
execute the page, the PHP code is not executed.  Is there anything else I
can try? 

To give you guys a little more background of what I'm trying to do... from a
web page a submit button is clicked and accesses a CGI script. The script
does what it needs to do and then prints out the html template (snippet
above). Within the .htm template there are 'place holders' denoted by
brackets '[ ]' i.e. [includes]. This is where the cgi script dynamically
adds content to the template.

I'm not familiar at all with CGI and how it uses 'templates' to generate the
web page but I think that's the overall idea of what's going on.

So what I'm looking to do is cut out the header and footer code of each
template (there are tons of them and the header and footer code is embedded
in each of them) and reuse one header and one footer by calling a PHP
include/method at the top and bottom of the .htm template?

Any advice will be greatly appreciated.

Thanks for the help.

- Billy -

On 4/26/04 12:35 PM, "jeffrey_n_Dyke@Keane.com" <jeffrey_n_Dyke@Keane.com>
wrote:

> 
> 
> 
>> I'm not sure if I can do what you are suggesting....
>> I tried putting some php code in an .htm file and the php
>> code never got executed so I stop attempting that route...
> 
> I've not followed this whole thread but if you wish to run php from an .htm
> file, you can add an .htaccess file
> to the directory where you want this to happen, and in that .htaccess file
> include these lines.
> 
> RemoveHandler .html .htm
> AddType application/x-httpd-php .php .htm .html
> 
> YMMV....HTH
> Jeff
> 
>> -------- Original Message --------
>> Subject: Re: [users@httpd] using php in header file
>> From: "tony wright" <apache@wrightone.co.uk>
>> Date: Mon, April 26, 2004 10:48 am
>> To: users@httpd.apache.org
>> 
>> All I am doing is using the headerfile directive. check google or apache
>> site.
>> this only shows on directory listings (where there is no index or other
>> page
>> displayed. )
>> regarding your problem, can't you just replace all the header code that
>> is
>> hardcoded with a couple of php lines to include a header file?
>> you could even use php to run through all your files doing the
>> replacement
>> 
>> tony
>> 
>> On Monday 26 April 2004 17:51, Billy Bacon wrote:
>>> Hi Tony,
>>> 
>>> I was wondering if you could give me some details on your setup. It
>> sounds
>>> like you are doing something similar to what I WANT to do but I
>> haven't
>>> figured out a way to do it.
>>> 
>>> My scenario:
>>> I inherited this site that is written in Perl/CGI. It uses
>> 'templates'
>>> which I wasn't aware of from the Perl/CGI world. In any case, the
>> header
>>> and footer section of the web site is hard coded in EVERY template
>> which is
>>> a maintanence nightmare for me. What I'd like to do is set up these
>>> Perl/CGI 'templates' (which are really just HTML files with a .htm
>>> extension) so that I can 'include' my header and footer that is
>> written in
>>> PHP. This will allow me to reuse my code obviously. But with Apache,
>> I
>>> don't know of a way that will allow me to do this since I'm new to
>> the
>>> Apache world.
>>> 
>>> I was wondering if what you are doing would solve my problem.
>>> 
>>> Any details, advice or suggestions would be awesome.
>>> 
>>> Thanks
>>> 
>>> - Billy -
>> 
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server
>> Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message