Page 1 of 1
Template question
Posted: Tue Jun 18, 2002 8:37 am
by ccjob2
I'm working on a site with a template system. I wish create 5 blocks: header, footer, body, left and right, that contain severals code.
The problem is that when I include header.html (for example) and footer.html the page is OK. But when I include also left.html (or right.html) the body.html content is displaied under left.html.
How can I display: the left.html, the body.html and the right.html all on the same row.
I tried with tables, but I don't know how to insert php content into a table definition.
Can you help ?
Thanks
Carlo
Posted: Tue Jun 18, 2002 8:48 am
by twigletmac
Try:
Code: Select all
<?php
include 'header.php';
echo <<<END
<table width="100%" cellpadding="5" cellspacing="0" border="0">
<tr>
<td width="20%">
END;
include 'navleft.php';
echo <<<END
</td>
<td width="60%">
END;
include 'content.php';
echo <<<END
</td>
<td width="20%">
END;
include 'navright.php';
echo <<<END
</td>
</tr>
</table>
END;
include 'footer.php';
?>
Obviously change table properties (cell widths etc.) and include file names to suit yourself.
Mac
Just a little more
Posted: Tue Jun 18, 2002 9:06 am
by BDKR
One question if. Are all of those includes actually different files?
If so, then each time a page loads, the server has to do an individual disk read for each of those include files. That's extremely inefficient!
However, if you make a file called html.php and convert each of those include files to functions that reside in html.php, then there is only one disc read that needs to be done.
Code: Select all
<?php
# This used to be header.php
function header()
{
/* header stuff */
}
# Once was navleft.php
function navleft()
{
/* navleft stuff */
}
# And so on and so on
?>
Hope that helps.
Later on,
BDKR (TRC)
What is END ?
Posted: Tue Jun 18, 2002 1:44 pm
by ccjob2
I don't know <<<END istruction (nor END;). Anyway Thank you very much for your helps.
Carlo
Posted: Tue Jun 18, 2002 1:51 pm
by twigletmac
All that the echo <<<END does is say to PHP parse this lot until you reach END;. Stuff echoed like this retains its formatting which can help with debugging HTML code. There's also the fact that you don't have to worry about escaping quotes (double or single). Personally I find that it's a method that works well for large blocks of HTML code with some PHP variables interspersed.
There's a bit of information about it in the manual as well (check the examples section):
http://www.php.net/manual/en/function.echo.php
Mac