Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
designing a good structure for a website
Old 12-17-2007, 05:15 PM designing a good structure for a website
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I'm working an a rather large project and I would say that I've completed it to 75%. But now I'm stuck, and have been for about a month :P. The problem is the lack of a good struckture design. I basically just started on a page, wrote some code to get it working and continued on the next one. Obviously that led to problems when different files needed to work together or classes be used by several scripts and I had to make big changes over and over again to make things work. It basically got more and more difficult the further I got. So I need to make up a good plan to follow and start from the beginning. Hopefully I can reuse much code to speed it up.

I have a couple of points on which I need help and guidance, but most of them will be quite long, so I start with just two that I have been thinong on alot and when those have been solved I can post another one :P

1) Is there any "better way" of organasing files and linking them? What I mean is, would it be better to use files like file1.php, file2.php (...) or index.php?page=file1, index.php?page=file2 (...) and including the contents? Is there any "better way" or is it just what a person likes best?

2) The website will have an admin login (no other logins), where I am the admin. When logged in, all pages will be displayed as normal but with some extra options. There will be a small admin menu with options corresponing to the viewed page and most things on the site will be editable.
How would I best do this? That is, what classes would I use and how should I structure them.
For a more concrete example, there will be a news page, consisting of news which all have a date, news text and possibly pictures. I figured I'll have a class 'NewsList' which is a list of news. It holds objects of a class 'News' wich is 1 seperate news (date, text, picture). One class can handle the login sytem for the admin. How would I design this smart, so that when logged in all the classes NewsList, News (etc.) will retrieve and display more information (which should not be visible for regular visitors) and be editable? Can I use lots of if/else statements in the classes or maybe extend them with admin classes (i.e. 'NewsListAdmin').

I appreciate all the help I can get, thanks!
lizciz
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 12-17-2007, 05:27 PM Re: designing a good structure for a website
JamieLewis's Avatar
Pretty Much a Big Deal...

Latest Blog Post:
Gooie
Posts: 385
Name: Jamie Lewis
Location: UK
Trades: 0
Heya,

Site Structure is a concept that can be debated until the cows walk downstairs, there is no right way, but there are plenty of wrong ones. You need to formulate a solution that allows you to quickly and efficiently add and delete pages (by quick and efficient I mean 1 click in the admin menu), once you have that (and there are several ways of doing it) you should have a decent structure.

Although it has been a while since I have had to build a site, I usually go with a modular based design controlled via a database. So the initial markup and back scripting of the site remains constant but new code and markup can be inserted by simply adding and removing entries to a table in the database.

For the admin functionality have a look into using sessions to display the extra detail, there are literally hundreds of tutorials on this very area around the net.

Hope that helped.

Jamie
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
JamieLewis is offline
Reply With Quote
View Public Profile Visit JamieLewis's homepage!
 
Old 12-17-2007, 05:29 PM Re: designing a good structure for a website
Experienced Talker

Posts: 30
Trades: 0
If I start a new project, these are steps I make:

- Make a config file (database connection, vars,....)
- Make an example page in html.
- seperate the html page in pieces (like the left menu, header, copyright, rightmenu) and make seperate include files from them, then include them on your example page (meanwhile php).
- you can then always add extra pages, beginnen from that example, and can easily change all otherthings around the main text area...

So it is almost the same having the (index.php?page=xx) module thing and you will also only see the middle text on each page...
klaroen is offline
Reply With Quote
View Public Profile
 
Old 12-19-2007, 07:54 AM Re: designing a good structure for a website
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Thank you both for your awnsers. I've done some more thinking and planning and I have actually restarted the project now. But instead of just starting with the coding as last time I've created empty files and classes, methods, fuctions etc. to get it all organized before the actual coding. So far it's working out great.

Right now I've only got one small question, which is a bit off the original topic, but still, here it is. What's your opinion on constants? For example, in my config file (thanks for the tip klareon) where I among other things store admin username and password, would it be ok to make constants out of those? I.e.
define("ADMIN_USERNAME", "...");
define("ADMIN_PASSWORD", "...");

Then to validate a login I would use an if statement as
if($uname === ADMIN_USERNAME && $pword === ADMIN_PASSWORD) { ... }

Is there any downside I fail to see? The reason I'm asking is that I've actually never used constant before.

Thanks
lizciz
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 12-23-2007, 05:41 AM Re: designing a good structure for a website
Experienced Talker

Posts: 30
Trades: 0
Sure, they are good to use..
You can make constants for a lot of things: website titel, passwords, emails, limit numbers ....
But acctually if you make constants in your config file, they don't really need to be constant he...
klaroen is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to designing a good structure for a website
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.56065 seconds with 12 queries