Hi Ogden,
You're almost there - and I think you can do what you want with a dhandler
in your root actually... but I went a different direction long time ago.
Consider this code very experimental, as I'm not anywhere near done with
this myself :)
I use a 404 handler by setting this in my Apache conf:
ErrorDocument 404 /error/notfound/
Then this in file /error/notfound/index.mhtml
<%perl>
my($urlword,$urlpath,$urlargs);
if( $ENV{REQUEST_URI} =~ /\/([\w\d_\.\-\
%]+)\/([\w\d_\.\-\/]+)\/([\w\d=?&%]+)$/i ) {
$urlword = $1;
$urlpath = $2;
$urlargs = $3;
}
#print "<p>Word = $urlword, Path = $urlpath, Args = $urlargs.</p>";
# Explode args and make a hash from it.
my %hash_args;
my($key,$val);
#print "Split out:<pre>".Dumper( split(/[\?&]/ ,$urlargs) )."</pre>";
my $item;
foreach( split(/[\?&]/ ,$urlargs) ) {
$item = $_;
if( $item =~ /=/ ) {
($key,$val) = split(/=/, $item);
$hash_args{$key} = $val;
}
}
#print "Hashed out:<pre>".Dumper(%hash_args)."</pre>";
eval {
$m->comp("/$urlpath/index.ni", urlword => $urlword, %hash_args);
};
</%perl>
Regards
- Nicolai
PS: If you could mail me some of your dhandler setup (snippets from A to Z)
I would appreciate it. I may need the inspiration for later :)
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of OgdenNefix
Sent: 21. juni 2007 20:43
To: [email protected]
Subject: [Mason] Dynamic Directory in URLs
Hello all,
I understand dhandlers and autohandlers to process URLs as such:
http://localhost/events/300
dhandler:
my $event = ( split /\//, $r->uri )[-1];
$m->comp( "show_event.mas", event => $event );
So that works fine and as expected.
However, how about:
http://localhost/tom_smith
Where it will grab tom_smith and grab the database ID for that username
and then take it to their profile.
Is this possible as a top level directory, even when there are other
directories such as /contact/, /help/, /members/, etc?
Thanks
Ogden
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users