Forum Moderators: coopster
Here is my issue I want to call them with a variable defined and held in a different file (config.php) then simply include the config.php file and anytime I use one of the variables like for instance {header}
the header file is included in the html
Thanks for any help on this!
You could do this in a number of ways. You mentioned you want to use a config file... Within that file you could do somethign like..
in this example this file would be layout.php
<?php
if ($layout =='1')
{
$header="header1.php";
$footer="footer1.php";
}if ($layout =='2')
{
$header="header2.php";
$footer="footer2.php";
}else
{
$header="defaultheader.php";
$footer="defaultfooter.php";
}
?>
Then on your actual page use somethign like the following...
<?php$layout=$_GET['layout'];
include"layout.php";include"$header";
echo"main content";
include"$footer";
?>
Then to set a layout you woudl pass the valuw in the url. www.example.com/page.php?layout=1
first we use $_GET to get the value from the url, we then include the layout.php file. the value will then be passed though this file and this will set the layout values. then when we include header and footer within the main file we are using a variable obtained from layout.php
Hope this gives you some ideas.
Mack.
what I am looking for is this:
I have a "home.php" file This is the file I am calling in the browser how ever the home.php is calling a home.html file that has the following:
{header}
***content****
{footer}
The {header} & {footer} variables include the header/footer into the final home.php which is being displayed in the browser
My question is how do I include the header & footer in that format instead of using the include statement in every file
Thank you for all your help!
Then within your page simple include the config file and specify a value
include"config.php";
$Value="1";
I wouldent try to pass the value with the include because the chances are this will not work...
include"config.php?value=1"; there is no reason to pass the value to the include because it will be placed inlibne with the main file and the value will be read in that way.
Another very rough way of doing this would be to place the html code for the header and footer file within a text file and name them header1.php header2.php ect ect
then from within your config file include the text files to generate the html within the file. then when the value is passed it will render the html code from the text files.
Perhaps if you provide a little bit more information about exactly what you are trying to acheive we may be able to opffer you some better ideas. Right now the suggestions you are receiving are very general.
Mack.