Jump to content
xisto Community
tricky77puzzle

Question About Php Includes How would you include a frame AROUND the page?

Recommended Posts

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)

<?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 Xisto, 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.

<html><?php include ("layout.php");echo $top;?>Put your content here!!!<?phpecho $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!

Share this post


Link to post
Share on other sites

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.

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

<?phpsession_start();include('includes/db.php');$title = "Welcome";$location = "index.php";$content = "includes/home_content.php";include('_core.php');?>

and heres my tempate

<?php/*Core template==============$titleinclude('menu_list.php');$content*/$title = $title." - Si Web Portfolio";echo"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://forums.xisto.com/no_longer_exists/ xmlns=\"http://forums.xisto.com/no_longer_exists/ 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://forums.xisto.com/no_longer_exists/        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.

Share this post


Link to post
Share on other sites

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!)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.