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
Template question
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Try:
Obviously change table properties (cell widths etc.) and include file names to suit yourself.
Mac
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';
?>Mac
Just a little more
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.
Hope that helps.
Later on,
BDKR (TRC)
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
?>Later on,
BDKR (TRC)
What is END ?
I don't know <<<END istruction (nor END;). Anyway Thank you very much for your helps.
Carlo
Carlo
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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
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