How do I structure my website?

Page 1 of 1

3 Replies - 739 Views - Last Post: 23 January 2012 - 04:37 AM

#1 skybomb0  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 92
  • Joined: 12-May 10

How do I structure my website?

Posted 01 May 2011 - 07:32 PM

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?

Is This A Good Question/Topic? 0
  • +

Replies To: How do I structure my website?

#2 Creecher  Icon User is offline

  • I don't care
  • member icon

Reputation: 561
  • View blog
  • Posts: 2,049
  • Joined: 06-March 10

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

<?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>&copy; 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.
Was This Post Helpful? 0
  • +
  • -

#3 skybomb0  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 92
  • Joined: 12-May 10

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!
Was This Post Helpful? 0
  • +
  • -

#4 Shane Hudson  Icon User is offline

  • D.I.C Technophile
  • member icon

Reputation: 343
  • View blog
  • Posts: 1,286
  • Joined: 06-December 09

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.

This post has been edited by Shane Hudson: 23 January 2012 - 04:42 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1