Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Question About Php Includes, How would you include a frame AROUND the page?
tricky77puzzle
post Feb 18 2008, 10:11 PM
Post #1


Super Member
*********

Group: [HOSTED]
Posts: 416
Joined: 26-January 08
Member No.: 56,881



I'm trying to make a layout for my website for the areas that aren't occupied by Wordpress, and I want to use PHP includes to do it.

So far, I know how to use <?php include ... ?> tags, like this:

CODE
<table>
<?php include "sidebar.php" ?>
</table>


This is okay, but I want to be able to include everything in one "container" file. Kind of like this:

For every HTML file that I include:
CODE
<html>
<head>
<?php include "frame.php" ?>
<title></title>
</head>
<body>
<!-- Include pure page content here -->
</body>
</html>


This is so that the HTML files I originally made stay HTML files except for the PHP sidebar I add, and I won't need any permalinks.

How would I go about doing this?
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 18 2008, 11:42 PM
Post #2


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,874
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



In order to have your 'html' pages parsed as PHP, you will need to create an .htaccess file and change the list of file extensions which should be parsed as php.
This is done by adding the htm and html file extensions to the php application handler.

There have been several Tutorials about how to do this. Here is one of them that is quite well explained.

http://www.trap17.com/forums/index.php?showtopic=46392
Go to the top of the page
 
+Quote Post
tricky77puzzle
post Feb 19 2008, 12:52 AM
Post #3


Super Member
*********

Group: [HOSTED]
Posts: 416
Joined: 26-January 08
Member No.: 56,881



QUOTE(jlhaslip @ Feb 18 2008, 06:42 PM) *
In order to have your 'html' pages parsed as PHP, you will need to create an .htaccess file and change the list of file extensions which should be parsed as php.
This is done by adding the htm and html file extensions to the php application handler.

There have been several Tutorials about how to do this. Here is one of them that is quite well explained.

http://www.trap17.com/forums/index.php?showtopic=46392


Sorry, I misphrased myself. I meant, I want my HTML files to stay the way they were, except for being renamed to PHP and having the sidebar added in as a "header".

I don't really feel like editing the .htaccess file.
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 19 2008, 01:35 AM
Post #4


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 3,874
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



If you want a 'common' snippet of php code added into all of your site pages, the system needs to know that the php is in there and that it needs to send the file to the php parser.

Two ways to do that:

1. rename the files with a php extension. ( you don't want to do that)
2. Add the above to your htaccess file. (you will need to do this)

Without the file extension, or the application/type redirect in your .Htaccess file, the php code will be treated as text and display on your page as raw code, possibly displaying stuff you don't want public, like Database Information.

You need to do one or the other.
Go to the top of the page
 
+Quote Post
tricky77puzzle
post Feb 19 2008, 01:55 AM
Post #5


Super Member
*********

Group: [HOSTED]
Posts: 416
Joined: 26-January 08
Member No.: 56,881



QUOTE(jlhaslip @ Feb 18 2008, 08:35 PM) *
If you want a 'common' snippet of php code added into all of your site pages, the system needs to know that the php is in there and that it needs to send the file to the php parser.

Two ways to do that:

1. rename the files with a php extension. ( you don't want to do that)
2. Add the above to your htaccess file. (you will need to do this)

Without the file extension, or the application/type redirect in your .Htaccess file, the php code will be treated as text and display on your page as raw code, possibly displaying stuff you don't want public, like Database Information.

You need to do one or the other.


Well, actually I do want to rename the files. I just want to know how I can build the site AROUND the pure code that exists as my HTML page. I just don't want to have to put the "table" stuff in every page, and would rather have all the table containers and stuff in one php file that I can put a <?php include "frame.php" ?> for in the page. That's my only problem.
Go to the top of the page
 
+Quote Post
truefusion
post Feb 19 2008, 03:46 AM
Post #6


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,861
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528
T17 GFX Crew



Are you basically saying you want a "header", a "footer" and a "content" file to be included all in one page as to act as a template to use as your main structure for your site? I'm having a bit of trouble understanding you, too.
Go to the top of the page
 
+Quote Post
[John]
post Feb 19 2008, 11:08 PM
Post #7


Newbie [Level 2]
**

Group: Members
Posts: 32
Joined: 19-February 08
Member No.: 58,129



The easiest way would be to have the content already inside the frame you are trying to include. if it is called content.php....

on the content.php page you can simply echo an iframe, and in the iframe use <?php include("page1.html") ?> or something of the sort. that way, once loaded, the content is already in the middle iframe. You can simple target iframes to change the content in the middle through links smile.gif
Go to the top of the page
 
+Quote Post
BuffaloHELP
post Feb 20 2008, 04:03 AM
Post #8


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,434
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



You can also perform PRINT or ECHO to spit out HTML codes, such that:

HTML
<?php

print '
<html>
<head>';

include "frame.php";

print '
<title></title>
</head>
<body>
<!-- Include pure page content here -->
</body>
</html>';

?>


You don't have to do any modification to your code and simply save this page as filen_name.php
Notice the usage of single quote verses double quote.
Go to the top of the page
 
+Quote Post
tricky77puzzle
post Feb 21 2008, 10:56 PM
Post #9


Super Member
*********

Group: [HOSTED]
Posts: 416
Joined: 26-January 08
Member No.: 56,881



QUOTE(truefusion @ Feb 18 2008, 10:46 PM) *
Are you basically saying you want a "header", a "footer" and a "content" file to be included all in one page as to act as a template to use as your main structure for your site? I'm having a bit of trouble understanding you, too.


Well, sort of. I want to be able to include the frame in one file, and reference it as a "header" file in the page content.

To [John], I don't want to use iframes, because that would defeat the purpose of using PHP for it.

I want to be able to include a top bar and a sidebar inside the include frame. Currently, the page layout I want looks like this:

CODE
<html>
<!-- include HTML header code here -->
<body>

<table id="page" width="100%">

    <tr><td>
    <table id="top-bar" height="148px">
    <tr><td width="172px"><img src="logo.png"></td><td><!--