News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

PHP include();, A very nifty trick

Started by angel_fromhel46, May 23, 2006, 07:10:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

angel_fromhel46


Even if you don't know any php this trick is easy to use and will save you a lot of time when updating the layout of you site.

1. First make the layout of your site, leaving the table or field where you want the main content to appear blank. Save it as a .php.

2. Then put the content in individual files as plain text/ content.

3. Insert this code in the content area of your layout file:

<?php
$page 
$_REQUEST['page'];
if(!
$page){$page main.html}
include(
$page);
?>



4. The last step in using this trick is to alter your hyperlinks. Instead of linking to main.html and guestbook.html and so on, you know link to ?page=main.html

That's it!
Here's an example to help you understand better:

index.php

<html>
<head>
<title>This is a test</title>
</head>
<body>
<a href=?page=main.html>Mainpage</a> - <a href=?page=second.html>Second page</a><br><br>
<?php
$page 
$_REQUEST['page'];
if(!
$page){$page main.html}
include(
$page);
?>

</body>
</html>



main.html

This is the mainpage...<br>
It is nice



second.html

This is another page...<br>
It is also nice