DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
Quick Search:  
Register Now! Welcome to Dnforum.com You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us.
Go Back   DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars > Content Development > Website Development and Design Discussion > Coding/Programming/Languages
Register Domains for $6.99 - GoDaddy.com
Reply
 
LinkBack Thread Tools Display Modes
Old 04-23-2008, 10:07 PM   #1 (permalink)
Platinum Lifetime Member
 
SGBoise's Avatar
 
Last Online: 05-15-2008 02:37 AM
iTrader: (1)
Join Date: Jan 2008
Posts: 10
DNF$: 60
Location: USA


Talking Better code for router/dispatcher

Hello,
I am trying to implement router/dispatcher for my script. I looked at how phpcake, codeigniter and zend framework work but they were way to complicated to what I needed.
I found a tutorial at http://www.phpaddiction.com/tags/axi...-php-part-one/ which is simple to implement.
I have two types of uri:
category / id / description.html
or
category / subcategory / id / description.html
Example: /videos/funny/234/funny_monkey_dancing.html

What I am trying to do is determine category and subcategory, if there is a subcategory, and then the ID.
The way I am doing it right now doesn't look like the proper way. Is there a better way to do this?

Here is my code from the tutorial with a few modifications.
PHP Code:
//$requestURI = explode('/', $_SERVER['REQUEST_URI']);
$requestURI explode('/'"tms_routing/videos/funny/234/funny_monkey_dancing.html");
$subfolder "tms_routing";
// Remove the subfolder
if (!$subfolder == "") {
 for(
$i0;$i sizeof($requestURI);$i++){
  if (
$requestURI[$i] == $subfolder){
   unset(
$requestURI[$i]);
   break;
  }
 }
}
// Map paths
if (is_numeric($requestURI[3])) {
 
$array["category"] = $requestURI[1];
 
$array["subcategory"] = $requestURI[2];
 
$array["id"] = $requestURI[3];
} else {
 
$array["category"] = $requestURI[1];
 
$array["id"] =  $requestURI[2];

__________________
GamePacks.org - Products for the Arcade/Media Community
TopMediaScript com - The ultimate media site script
AutoVideoScript com - Run your own youtube sharing site
SGBoise is offline   Reply With Quote
Old 04-23-2008, 10:09 PM   #2 (permalink)
www.LOL.biz
 
Bender's Avatar
 
Name: Daniel
Last Online: Yesterday 09:49 PM
iTrader: (12)
Join Date: Apr 2004
Posts: 1,743
DNF$: 5,006
Location: .ro
Country:


nice hat!
have you considered doing this with mod_rewrite?
Bender is offline   Reply With Quote
Old 04-23-2008, 10:23 PM   #3 (permalink)
Platinum Lifetime Member
 
SGBoise's Avatar
 
Last Online: 05-15-2008 02:37 AM
iTrader: (1)
Join Date: Jan 2008
Posts: 10
DNF$: 60
Location: USA


Quote:
Originally Posted by Bender View Post
nice hat!
have you considered doing this with mod_rewrite?
Thanks.

I am using rewrite to redirect to default.php. I can't use static redirects because the category and subcategory can be changed.
__________________
GamePacks.org - Products for the Arcade/Media Community
TopMediaScript com - The ultimate media site script
AutoVideoScript com - Run your own youtube sharing site
SGBoise is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules

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


All times are GMT -4. The time now is 12:44 AM.
Copyright @2001-2008 DNForum.com