I have a small website currently, but as I add more content, the website grows in complexity. Right now, I have a bunch of php files for each different part of the website. So there is a header.php, a footer.php, a title.php. I also have an article.php that takes a get parameter which is a relative path to a text file that I want to display. I have limited php and web development knowledge, so I want to get the structure right before I go any further or get into bad habits.
My site is going to display articles, code snippets, and videos. How would you structure the website?
How do I structure my website?
Page 1 of 13 Replies - 628 Views - Last Post: 23 January 2012 - 04:37 AM
Replies To: How do I structure my website?
#2
Re: How do I structure my website?
Posted 01 May 2011 - 08:20 PM
One thing you could do is create a file like "common.php" and put everything from your header, fooer, title, ect., and put them in their own custom functions, include common.php on your page, and then call the function.
For example:
common.php
Then call it like so:
All of these are taken from my website and are the way I prefer to do it. Others will probably give you a better method.
For example:
common.php
<?php
function ShowMenu()
{
echo'<div id="sidebar">
<h2>Navigation</h2>
<ul>
<li><a href="index.php">Main</a></li>
<li><a href="index.php?id=projects">Projects</a></li>
<li><a href="index.php?id=contact">Contact</a></li>
<li><a href="index.php?id=links">Links</a></li>
</ul>
</div>';
}
function ShowHead()
{
echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Personal website hosting the projects of Logan Creech" />
<title>Logan Creech</title>
<link href="http://neverpool.com/style.css" rel="stylesheet" type="text/css" />
</head>
<body>';
}
function ShowFoot()
{
echo'<div id="footer">
<p>© Logan Creech 2011</p>
</div>
</div>
</body>
</html>';
}
?>
Then call it like so:
<?php
include('common.php');
ShowHead();
?>
<div id="wrap">
<div id="header"><h1>Logan Creech Programming</h1></div>
<div id="main">
<br />
<br />
<p>OSAMA BIN LADEN IS DEAD! <a href="http://www.reuters.com/article/2011/05/02/us-obama-statement-idUSTRE74107920110502">Link</a></p>
<p><object width="640" height="510"><param name="movie" value="http://www.youtube.com/v/sWS-FoXbjVI?fs=1&hl=en_US&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/sWS-FoXbjVI?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" width="640" height="510" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
</div>
<div id="sidebar">
<?php
ShowMenu();
echo '</div>';
ShowFoot();
?>
All of these are taken from my website and are the way I prefer to do it. Others will probably give you a better method.
#3
Re: How do I structure my website?
Posted 02 May 2011 - 06:41 AM
So it's kind of like what I have. I just have to put each file into a method and put all of the methods in the same file. Thanks!
#4
Re: How do I structure my website?
Posted 23 January 2012 - 04:37 AM
There are many ways to structure it, you seem to have the jist. I do wonder however, what is in title.php? Usually the title would go in header.php?
EDIT: Ah, I did not read the date. I shall lock this thread as a new member started posting non-useful content in it.
EDIT: Ah, I did not read the date. I shall lock this thread as a new member started posting non-useful content in it.
This post has been edited by Shane Hudson: 23 January 2012 - 04:42 AM
Page 1 of 1
|
|

New Topic/Question
This topic is locked



MultiQuote




|