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 District_posters, May 22, 2006, 08:39:31 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

onlygodcanjudgemee

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