View Full Version : multiple directories, single codebase [kinda long, sorry]

12-28-2008, 07:37 PM
I am making a website that will be similar to Yahoo groups but for a specific purpose. All groups will be made by myself, not registered by users (this is on purpose, however I will be adding groups every once in a while). What I want is like this:

[mysql tables]


I want the groups like http://example.com/category/groupname/index.php (there can be multiple with the same "groupname" but in different categories)

so lets say we have these sites:

http://example.com/fun/boringgroup/ // id 1
http://example.com/fun/awesomegroup/ // 2
http://example.com/school/awesomegroup/ // 3
http://example.com/random/milk/ // 4

All of that I could do on my own, just copy a group's fileset, change values, add tables, etc.

I also know that I can save the category/groupname in another table called "groups" liek this:

table `groups`
columns: gid, name, category

and make it search there to find the group id based on the url, then look in g<id>_* for that group.

The problems come in after that. I don't want to copy the files over and over, as it would make it a nightmare to change something for each group. Since every group is going to have the same options but different configuration (saved in the database table `g<id>_settings`), I decided it would be best to use a single fileset (maybe http://example.com/comm/). Here are the issues I face with that:

1. Although I can figure out what tables to use based on the URL, I don't know how to make it retrieve the files from http://example.com/comm/
2. Even if I knew a way to make it display the file, I don't know how I would do anything relating to $_POST such as logins.

I think I could solve problem 2 by making the login form's action be the standard user login page (which would be http://example.com/comm/user.php?act=login) and pass along a $_POST variable 'gid' and then, after logging in, go back to the correct group based on the gid. It would need this gid anyway so it knows which table to check the users from, so this would just be a slight modification. Is that a decent way to do it?

As for problem 1, I was thinking make a single index page for each one where it will take anything in the query string and look for it, so for example:

[page].php?[query string]

> http://example.com/comm/user.php?act=login

> http://example.com/comm/topic.php?id=37

Any opinions/suggestions on any of this?

Thanks for reading all that long boring stuff, I look forward to hearing what I did wrong:)