tricky77puzzle
Feb 18 2008, 10:11 PM
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?
Reply
jlhaslip
Feb 18 2008, 11: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
Reply
tricky77puzzle
Feb 19 2008, 12:52 AM
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=46392Sorry, 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.
Reply
jlhaslip
Feb 19 2008, 01:35 AM
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.
Reply
tricky77puzzle
Feb 19 2008, 01:55 AM
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.
Reply
truefusion
Feb 19 2008, 03:46 AM
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.
Reply
[John]
Feb 19 2008, 11:08 PM
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
Reply
BuffaloHELP
Feb 20 2008, 04:03 AM
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.
Reply
tricky77puzzle
Feb 21 2008, 10:56 PM
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><!-- title --></td></tr> </table> </td></tr>
<tr><td> <table id="sidebar" width="256px"> <!-- does the "width" and "height" option go into CSS? I don't remember. --> <tr style="background-image: sidebar-top.png;"><!-- link to home page --></tr> <tr style="background-image: sidebar-middle.png; background-repeat: repeat;"><!-- other links --></tr> <tr style="background-image: sidebar-bottom.png;"><!-- spotlight link: possibly to Trap17, maybe an ad or two --></tr> </table> </td><td> <!-- insert pure page content here --> </td></tr>
</table>
</body> </html> As you can see, it's quite a simple page layout. Now what I want to do is to cut out everything except for the pure page content and the includes that I want to add. How would I go about doing that?
Reply
KansukeKojima
Feb 21 2008, 11:08 PM
I believe I understand what you are saying... If I understand correctly: you want to have a basic template seperated from the the rest of your content, and then just parse the content into the template, or the template around the content right? If this is the case I would recommend using this. CODE <?php //---------------------------------- // Content Include //---------------------------------- $cont = $_GET['cont'];
$default = "HOME PAGE FILE HERE";
if($cont == "") { $cont = $default; }
elseif(isset($cont)) { $cont = $cont; }
if(file_exists("$cont.html")) { $content = file_get_contents("$cont.html"); } else { $content = "Unfortunately, the file you were looking for could not be located."; } //---------------------------------- // Content Select //----------------------------------
if(isset($cont)) { $content_select = <<< html $content html; } else { $content_select = <<< html There is a content_select error. html; }
//--------------------------------- //Template //---------------------------------
$template = <<< html <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><!-- title --></td></tr> </table> </td></tr>
<tr><td> <table id="sidebar" width="256px"> <!-- does the "width" and "height" option go into CSS? I don't remember. --> <tr style="background-image: sidebar-top.png;"><!-- link to home page --></tr> <tr style="background-image: sidebar-middle.png; background-repeat: repeat;"><!-- other links --></tr> <tr style="background-image: sidebar-bottom.png;"><!-- spotlight link: possibly to Trap17, maybe an ad or two --></tr> </table> </td><td> <!-- THIS IS WHERE YOUR CONTENT WOULD BE PARSED INTO THE PAGE--!> $content_select <!-- THIS IS WHERE YOUR CONTENT WOULD BE PARSED INTO THE PAGE--!> </td></tr>
</table>
</body> </html>
html;
//---------------------------------- // Display the Final Template //---------------------------------- echo $template; ?> After you create the above index.php file, create all your content on seperate .html files. For your links, simply use "<a href="index.php?cont=page">" Without the .html extension, as it will be placed in after the file name.
Reply
Latest Entries
KansukeKojima
Feb 22 2008, 09:18 PM
QUOTE(tricky77puzzle @ Feb 22 2008, 01:29 PM)  Yes, this is exactly what I wanted. Thanks, Kansuke! You arrrr welcome..... let me know if it works or not... I hope it does... (by the way: you owe me your soul!)
Reply
sonesay
Feb 22 2008, 08:37 PM
In effect what your using kansuke is a template. Thats what how I do my webpages at the moment. The only improvements that I think you can make are include the full HTML in your layout.php. That way you can contorl everything such as headings, javascripts includes, CSS. now when you need to make changes to the site you just edit the layout.php template and it will affect your whole website. when you use it you can create a page (example.php) and pass it variable specific to that page. CODE example.php
$title $content = "example_content.php" (I always do this as in include in the actual template)
include('layout.php');
So first thing you would do is create a plain HTML layout you like and set where you content and items will be. Then identifiy what changes and make place holders in your template for it. Then when you are happy with it you turn it into a PHP file being the templat you will use for all your pages. Now when you need a page or extra one you just create one and pass it the variables appropriate to it. Heres an example of my index.php page CODE <?php
session_start(); include('includes/db.php');
$title = "Welcome"; $location = "index.php"; $content = "includes/home_content.php";
include('_core.php');
?>
and heres my tempate CODE <?php /* Core template ============== $title include('menu_list.php'); $content
*/ $title = $title." - Si Web Portfolio";
echo" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" /> <title>$title</title> <script type='text/javascript' src='js/si.js'></script> <link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\" /> </head>
<body> <!-- Begin Wrapper --> <div id=\"wrapper\"> <!-- Begin Header --> <div id=\"header\"> <div id=\"header_leftside\"></div> <div id=\"header_rightside\"></div> <div id=\"header_center\"> <div id=\"header_logo\"></div> </div> </div> <!-- End Header --> <!-- Begin sub_heading --> <div class=\"container\"> <div id=\"sh_center\"> <div id=\"sh_block\"> <img src=\"images/si_15.png\" alt=\"\" /> </div> </div> <div id=\"sh_left\"></div> <div id=\"sh_right\"></div> </div> <!-- End sub_heading --> <!-- MAIN CONTENT --> <div id=\"content_container\"> <div id=\"leftsidebar\" class=\"leftbar\"> <div id=\"left_nav_container\"> <ul class=\"navigation\">"; // include menu list include('menu_list.php');
echo" </ul> </div> <div id=\"left_nav_footer\"></div> </div> <div id=\"maincontent\" class=\"centerbar\"> <div id=\"center_content\">"; // include Content if($content != "") include($content); else { // default notice echo"<h1>No content</h1>"; echo"<p>"; echo"There has been no content added in this section yet. Please return back later at a later date. Thank You!"; echo"</p>"; } echo" </div> <div id=\"si_closing\"><img src=\"images/si_closing.png\" alt=\"\" /></div> </div> <div id=\"rightsidebar\" class=\"rightbar\"> </div> </div> <!-- MAIN CONTENT END --> <!-- Begin Footer --> <div id=\"footer_container\"> <div class=\"footer_centerbar\"> </div> <div class=\"footer_leftbar\"> </div> <div class=\"footer_rightbar\"> </div> </div> <div id=\"footer_notice\"> <a href=\"http://validator.w3.org/check?uri=referer\"><img src=\"http://www.w3.org/Icons/valid-xhtml10-blue\" alt=\"Valid XHTML 1.0 Strict\" height=\"31\" width=\"88\" /></a> </div> <!-- End Footer --> </div> <!-- End Wrapper --> </body> </html> ";
?>
Hope this gives you some ideas on how to do things. Theres always more then one ways to do something but what ever is easier for you and works should be good enough. This is the method I have just picked up while doing websites. I used to copy and paste the whole layout to each page not too long ago lol.
Reply
tricky77puzzle
Feb 22 2008, 08:29 PM
QUOTE(KansukeKojima @ Feb 22 2008, 02:35 PM)  Ok what you could do: Create a php file that contains the layout of your page. make it look somewhat like this (call it layout.php) CODE <?php //--------------------------------- //Layout top section //--------------------------------- $top = <<< 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><!-- title --></td></tr> </table> </td></tr>
<tr><td> <table id="sidebar" width="256px"> <!-- does the "width" and "height" option go into CSS? I don't remember. --> <tr style="background-image: sidebar-top.png;"><!-- link to home page --></tr> <tr style="background-image: sidebar-middle.png; background-repeat: repeat;"><!-- other links --></tr> <tr style="background-image: sidebar-bottom.png;"><!-- spotlight link: possibly to Trap17, maybe an ad or two --></tr> </table> </td><td> html; //--------------------------------- //Layout bottom section //---------------------------------
$bottom = <<< html </td></tr>
</table>
</body> html; ?> Ok, so in this you have two variables. The first being the 'top' part of your layout. This would be everything before your 'pure content' areas. The second variable is the 'bottom' part of your layout. This would be everything after your 'purecontent' area. So in short it would look like this. $top content $bottom Now here is where what you want comes into play. You can echo your entire layout around your content like this. CODE <html> <?php include ("layout.php"); echo $top; ?> Put your content here!!! <?php echo $bottom; ?> </html> I think this should work... maybe jlhaslip or another member more expierienced than me could point out any flaws if any... and I hope this is what you were looking for.... Yes, this is exactly what I wanted. Thanks, Kansuke!
Reply
KansukeKojima
Feb 22 2008, 07:35 PM
Ok what you could do: Create a php file that contains the layout of your page. make it look somewhat like this (call it layout.php) CODE <?php //--------------------------------- //Layout top section //--------------------------------- $top = <<< 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><!-- title --></td></tr> </table> </td></tr>
<tr><td> <table id="sidebar" width="256px"> <!-- does the "width" and "height" option go into CSS? I don't remember. --> <tr style="background-image: sidebar-top.png;"><!-- link to home page --></tr> <tr style="background-image: sidebar-middle.png; background-repeat: repeat;"><!-- other links --></tr> <tr style="background-image: sidebar-bottom.png;"><!-- spotlight link: possibly to Trap17, maybe an ad or two --></tr> </table> </td><td> html; //--------------------------------- //Layout bottom section //---------------------------------
$bottom = <<< html </td></tr>
</table>
</body> html; ?> Ok, so in this you have two variables. The first being the 'top' part of your layout. This would be everything before your 'pure content' areas. The second variable is the 'bottom' part of your layout. This would be everything after your 'purecontent' area. So in short it would look like this. $top content $bottom Now here is where what you want comes into play. You can echo your entire layout around your content like this. CODE <html> <?php include ("layout.php"); echo $top; ?> Put your content here!!! <?php echo $bottom; ?> </html> I think this should work... maybe jlhaslip or another member more expierienced than me could point out any flaws if any... and I hope this is what you were looking for....
Reply
tricky77puzzle
Feb 21 2008, 11:48 PM
QUOTE(KansukeKojima @ Feb 21 2008, 06:17 PM)  So you want all of your websites content to be in a single file? No, that's not what I meant. I mean that I want the container to be 1 page, and then all the other files will link to it with the PHP include. Sorry if I'm messing myself up.
Reply
Similar Topics
Keywords : php, includes, include, frame, page,
- [php]diffrent Type Of Template [id] With Includes ;)
(13)
Designing Index Page With Target
- the table instead of using frame (13) I have been reading up on search engine's ability to cache one's site and I realized that
FRAME is something these search engines don't really like. You can read it on Google's
search FAQ and just recently my page was cached by Yahoo after taking down my frame index page to no
frame page. So here is what I would like to do and I would like you super coders help. PHP seems
to be the best choice since when using INCLUDE command my index page includes not only my three
separate pages in one, but it helps to have content rather than showing only HTML FR....
Garbage Text
when i added php includes to a page (2) When i added php included to a page, it produced this really really weird garbage text befor and
after the table i have on the page. I was wondering if this has ever happened to anyone else. Not
sure what's producing the gargabe, i mean it's only a couple of characters, and i've
gone through everything and can't find anything. The other thing is that i can, and have gotten
rid of it by getting rid of the text befor the php include code which isn't a solution becasue i
want to keep the meta's and title on the page. this is what the garbage looks li....
Secure Page Includes Non-secure File
(1) The basic page layout I am working with has several includes on it (header.php, rightcolumn.php,
leftcolum.php and so on), and it is on httpdocs folder. I have also instanced some classes wich I
call at the beginnig of the home page. My problem arises when I try to run another page wich is
supposed to be secure (placed, obviously, at httpsdocs folder), and both secure and non-secure page
has the same layout?. What should I do? Make exact copies of the included files, classes and images
inside the secure folder? Is there a way to call my classes, includes from SSL folder....
Looking for php, includes, include, frame, page,
|
|
Searching Video's for php, includes, include, frame, page,
|
advertisement
|
|