How to properly organize a website?
Posted: Sat Jan 30, 2010 3:17 pm
Hello, I'm a newb at web development, but am pretty proficient at developing desktop software. Currently I am working on a web frontend to an inventory database at work, and on a personal website at home. At work I am using java and JSPs, and for the personal website I'm using PHP (because that's all that my $10/yr webhost supports, and I don't want to switch to something that's $10/month).
Also, you should know that for development I'm using exclusively NetBeans. The only other HTML editor I have access to is Microsoft Expression Web, but I don't like it very much. Dreamweaver is too expensive for me.
So, my main question is how to organize a website. Because I think right now both my work and personal websites are organized very oddly. Here is the body of index.php from my personal site:
Basically, the index.php file acts as a wrapper around all the other content on my page. When ever you click on a Menu or SubNav link it will call the javascript function changePageAndNav which just changes the URL parameters, it's code is:
This will reload index.php and will cause it to include the proper page and navigation bar. The included pages contain the bare minimum amount of code, without any body tags.
The plus side to doing things this way is consistent layout of the page, and very little duplicated code. And if I ever want to change the layout, I only need to change index.php.
On the negative side, I am left with large ugly url's that people can mess with. Such as:
Also, you should know that for development I'm using exclusively NetBeans. The only other HTML editor I have access to is Microsoft Expression Web, but I don't like it very much. Dreamweaver is too expensive for me.
So, my main question is how to organize a website. Because I think right now both my work and personal websites are organized very oddly. Here is the body of index.php from my personal site:
Code: Select all
<body>
<div id="wrap">
<div id="header">
<h1>Yet Another Homepage</h1>
<h2>By (My Name)</h2>
</div>
<div id="menu">
<ul>
<li><a href="index.php" >Home</a></li>
<li><a onclick="changePageAndNav('Projects/main.php', 'Projects/projectsNav.php');">Projects</a></li>
<li><a onclick="changePageAndNav('About/main.php', 'About/aboutNav.php');">About Me</a></li>
</ul>
</div>
<div id="content">
<div class="right">
<?php
if ($_GET["page"] == null) {
include "Home/main.php";
} else {
include $_GET["page"];
}
?>
</div>
<div class="left">
<?php
if ($_GET["subNav"] != null) {
include $_GET["subNav"];
}?>
</div>
<div id="bottom">
<a onClick="toTop();">Back to Top</a>
</div>
</div>
<div id="footer">
<p>© (My Name), 2009</p>
</div>
</div>
</body>
Code: Select all
function changePageAndNav(page, subNav){
window.location = "?page=" + page + "&subNav=" + subNav;
}The plus side to doing things this way is consistent layout of the page, and very little duplicated code. And if I ever want to change the layout, I only need to change index.php.
On the negative side, I am left with large ugly url's that people can mess with. Such as:
Can anyone suggest a better way to organize the website?