Re: including HTML
| From: | Alexander Ross | Date: | Wed, 07 Aug 2002 15:23:17 +0000 |
| Subject: | Re: including HTML | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111521@lists.php.net to get a copy of this message | ||
My problem is this ... my client hasn't the first clue about editing HTML,
but he can make simple changes in Dreamweaver. So lets say the name of his
company changes (for example) and the text at the very top of the screen
which said HAPPY CO. now says HAPPY & SONS. Now this has to change on my
dynamically created pages as well.
Because of this I can't just add a couple functions to an output.php file
(which is what I would normally do) nor do I want my client to have to make
chages to a picemeil html file (i.e. without a body tag or an html tag) from
within dreamweaver because DW will yell at him.
So my first thought was:
<?
inlude (index.html, line 10 - line 58)
dynamically do some fun stuff
incluide (index.html line 234 - line 284)
?>
Obviously this isn't real code, but I want to do something like that .. I
can easily put in a comment or a hidden field to deliniate the start/end of
each section I want ot include from index.html, (i.e. <!--HERE--> but I
don't know what to do next.
"Lowell Allen" <la@lowellallen.com> wrote in message
news:B975E26B.BCE2%la@lowellallen.com...
> > From: "Alexander Ross" <alexross@bleen.net>
> >
> > Can you include an HTML file up to a certain point. Basically I have a
.php
> > which I want to have a static header and a static footer (the same as
teh
> > header and footer of everyother page on this site) and then dynamic
content
> > in the middle. Is there a way to include each line of html in
index.html
> > untill I hit a line with <!--HERE --> (or some other comment?). If so,
how
> > can I then do the opposit and include each line of HTML from <!--HERE-->
to
> > teh end of the page?
> >
> If I understand you correctly, the answer is, "yes, it's very easy". When
> doing pages that are basically static, I still use PHP for simple
includes,
> which allows global changes to the header, menu, footer, etc. to be made
in
> just one place. Just create a file called "output_fns.php" and define
> functions to write the HTML fragments you desire, like:
>
> <?
>
> function do_html_header($title)
> {
> ?>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <title><?=$title?></title>
> </head>
> <body>
> <?
> }
>
> function do_footer()
> {
> ?>
> </body>
> </html>
> <?
> }
>
> ?>
>
> Then do pages like:
>
> <?
> require_once("output_fns.php");
> do_html_header("Whatever");
>
> // more PHP (or HTML)
>
> do_footer();
> ?>
>
> --
> Lowell Allen
>