Forum Moderators: phranque

Message Too Old, No Replies

Site layout (server side)

         

supermanjnk

1:57 am on Jan 27, 2005 (gmt 0)

10+ Year Member



I'm wondering what would be the best way to lay out a website, right now my index looks like this, (By the way I am using php):
<? include ('config.php')?>
<html>

<head>

<title>Site</title>

<link href="style/style.css" rel="stylesheet" type="text/css">
<? include ('menu.php')?>
</head>

<body>

<? include ('header.php')?>

<? include ('left.php')?>

<? include ('right.php')?>

<? include ('center.php')?>

<? include ('footer.php')?>

</div>

</body>

</html>

What i'm wondering is rather then including things that have the layout in them would it be better to have the layout in the index (the divs in the index file instead of included) and then include the content/server side stuff or is the way i have it fine? let me know if I need to be more clear.

also i have in my apache sites settings a default path for includes (being the includes folder on the site, would it be easier to just not have an includes folder?

tomda

8:04 am on Jan 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not a professional, so I can't tell you if the way I proceed is the best way (well, compare to the one you learn in school I suppose).

As you, I have a conf include at the beginning of each file, this include will get all important variable such as url_root, username, etc...

For the <head>, I have an include called head_tag.php


<?php
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>\r\n";
header("Content-Type: text/html; charset=\".$charset.\"");

echo "<html><head>\r\n<title>".$metatagtitle."</title>\r\n";
echo "<meta http-equiv='Content-Type' content='text/html;charset=".$charset."'>\r\n";
if ($print=="1") {echo "<meta name='robots' content='none'>\r\n<meta name='copyright' content='2003-2004 - #*$!x'>\r\n<meta http-equiv='Content-Language' content='".$langmetatag."'><meta name='robots' content='none'>\r\n";}
else {echo "<meta name='robots' content='".$robotsmetatag."'>\r\n<meta name='description' content='".$descrmetatag."'>\r\n<meta name='keywords' content='".$keywordsmetatag."'>\r\n";
echo "<meta name='copyright' content='2003-2004 - xxxx'>\r\n<meta http-equiv='Content-Language' content='".$langmetatag."'>\r\n";}
echo "<link rel='shortcut icon' href='".$url_root."images/favicon.ico'>\r\n";
echo "<link rel='alternate' media='print' href='".$mediaprint."'>\r\n";
echo "<link rel='stylesheet' type='text/css' href='".$url_root."style.css'>\r\n";
echo "<style type='text/css'>@import url(".$url_root."style.css);</style>\r\n";}
?>

Then, my html file is as follow


// ****************************
// CREATE HEAD TAG HEAD/HEAD
// ****************************
$metatagtitle = "Your title";
if ($print=="1") {$robotsmetatag="none";} else {$robotsmetatag="all";}
$descrmetatag="Your description for the page";
$keywordsmetatag="Your keyword for the page";
$langmetatag="en";
$mediaprint="".$url_root."xxxx.php?print=1";
include_once ("root/head_tag.php");

Hope you understand the way it works...

For the div problem, I can't answer you coz I never used a three/two column layer.

About the include file configuration, I had the same problem knowing that my server has one include per DNS and I found it difficult to have one include files in my localhost. So I have in my conf file the following, a switch statement (0=localhost and 1=server) and when switch=0 (that is localhost), I modify the php.ini (things I can't do in the server host)


// SWITCH
$switch="0";
// $switch="1";

// SERVER VARIABLE
//echo "<p class=note>HTTP_HOST: ".$_SERVER['HTTP_HOST']."<br>HTTP_REFERER: ".$_SERVER['HTTP_REFERER']."<br>DOCUMENT_ROOT: ".$_SERVER['DOCUMENT_ROOT']."<br>QUERY_STRING: ".$_SERVER['QUERY_STRING']."<br>REQUEST_METHOD: ".$_SERVER['REQUEST_METHOD']."<br>PHP_SELF: ".$_SERVER['PHP_SELF']."</p>";

$http_dir="your_file_name_root.com";
$docserver_root=str_replace("/","\\",$_SERVER['DOCUMENT_ROOT']);
$phpself= str_replace("/".$http_dir."/","",$_SERVER['PHP_SELF']);

// GET INCLUDE FOLDER
if ($switch=="0") {ini_set("include_path", ".;".$docserver_root."\\".$http_dir."\include");}

Well, it took me ages to find out all this. Any improvment or comment on the above code are welcome

Tomda

jorj

10:48 am on Jan 28, 2005 (gmt 0)

10+ Year Member



Get a template engine such as Smarty.sourceforge.net and you'll have the sepparation between logic and design.