Home > Archive > PHP DB > April 2004 > Re: [PHP] Adding includes to files
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP] Adding includes to files
|
|
| John W. Holmes 2004-04-22, 1:30 pm |
| From: "Robert Sossomon" <robert@gcnorris.com>
> I need to add PHP calls to include a file to each page as it is
> generated, the only thing is I can't get the includes to come through
> correctly:
>
> <! Code>
> $display_block .= "<?php include(\"nav/top_nav.html\"); ?>";
> $display_block .= "<?php include(\"nav/side_nav.html\"); ?>";
> <! End Code>
>
> At the end of the generation I write $display_block to a file as
You can use output buffering:
ob_start();
include("nav/top_nav.html");
include("nav/side_nav.html");
$display_block = ob_get_contents();
ob_end_clean();
---John Holmes...
| |
| Robert Sossomon 2004-04-22, 1:31 pm |
| Output buffering isn't going to help, the files, when completed need to
look like:
<! HTML CODE>
<HTML>
<HEAD>
<TITLE>Categories of Items</TITLE>
<BODY>
<?php
include("nav/top_nav.html");
?>
<?php
include("nav/side_nav.html");
?>
Html content
<?php
include("nav/bottom_nav.html");
?>
<! END HTML CODE>
If all I was trying to do was pull in the files I could do that without
a problem, but what I need to do is generate the whole page with the
information.
I attached the php file that does the site generation and maybe it will
shed some light on what I am trying to do as well.
TIA!!
Robert
-----Original Message-----
From: John W. Holmes [mailto:holmes072000@charter.net]
Sent: Thursday, April 22, 2004 11:33 AM
To: robert@gcnorris.com; php-db@lists.php.net; php-general@lists.php.net
Subject: Re: [PHP] Adding includes to files
From: "Robert Sossomon" <robert@gcnorris.com>
> I need to add PHP calls to include a file to each page as it is
> generated, the only thing is I can't get the includes to come through
> correctly:
>
> <! Code>
> $display_block .= "<?php include(\"nav/top_nav.html\"); ?>";
> $display_block .= "<?php include(\"nav/side_nav.html\"); ?>"; <!
> End Code>
>
> At the end of the generation I write $display_block to a file as
You can use output buffering:
ob_start();
include("nav/top_nav.html");
include("nav/side_nav.html");
$display_block = ob_get_contents();
ob_end_clean();
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
| |
| Robert Sossomon 2004-04-22, 2:33 pm |
| OK, so I figured out where it was barfing. I looked deeper into the log
files as well as the generated pages, and found that somewhere the path
to the include files had become mangled, and the reason the files
weren't showing correctly in the HTML pages in the browser was because
it couldn't find the right files. It's on track and working all neat
and tidy now.
Thanks for the help guys! I still feel like a doofus though...
Robert
-----Original Message-----
From: Richard Harb [mailto:rharb@earthling.net]
Sent: Thursday, April 22, 2004 11:46 AM
To: Robert Sossomon
Cc: php-db@lists.php.net; php-general@lists.php.net
Subject: Re: [PHP] Adding includes to files
You could either include the files without assigning the contents to a
variable - but that would display those right away:
<?php include('nav/top_nav.html'); ?>
or you could read the contents of the file like:
<?php $display_block .= is_readable('nav/top_nav.html') ?
file_get_contents('nav/top_nav.html') : ''; ?>
Richard
Thursday, April 22, 2004, 5:12:21 PM, thus was written:
> I need to add PHP calls to include a file to each page as it is
> generated, the only thing is I can't get the includes to come through
> correctly:
> <! Code>
> $display_block .= "<?php include(\"nav/top_nav.html\"); ?>";
> $display_block .= "<?php include(\"nav/side_nav.html\"); ?>"; <!
> End Code>
> At the end of the generation I write $display_block to a file as
> $display_block holds all the data it accumulates through the run. How
> do I rewrite the inlclude to work, or do I need to find another way to
> make the includes? The includes are all template files that I used on
> the site to keep everything consistent.
> Thanks,
> Robert
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|
|
|
|
|