Posted by billnbell on May 13, 2009 at 6:42am
How do I change the URL on my Drupal install to be like twitter:
This would be the same as /user/1 in drupal.
<?php
function liketwitter_menu() {
$items['%'] = array(
'page callback' => 'liketwitter_url',
'page arguments' => array(0),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK
);
return $items;
}
function liketwitter_url($username) {
// Here do a node load. It would be ideal if a drupal_goto is not required. Maybe forward/reverse proxy?
$nid = node_load(....);
drupal_goto(drupal_get_path_alias("user/$nid"), NULL, NULL, 301);
}
?>Maybe a combo of apache reverse proxy and drupal menu?
Anyone done this?
Comments
Have you tried Me Alias module?
http://drupal.org/project/me
David Wheeler, Ph.D.
http://RelaxNow.Org
http://twitter.com/DavidWheelerPhD
Hmmm
This is good, but not exactly what I want.... In Java I would create a Tomcat filter to do this... Not sure the facility in PHP....
Bill
Pathauto?
I'm confused... wouldn't pathauto handle this?? drupal.org/project/pathauto
You can set your user profile alias to just be [user-raw]. My current install (I think default) uses users/[user-raw]
The only issue with this is you have to ensure that none of your normal content ever uses a root path.... but using something like twitter's style you could use for your default node type alias to be:
[author-name-raw]/status/datestamp
I don't see an actual timestamp token in pathauto, but you could use a combination of the available date tokens and there you go.
Unless I misunderstand the need, this would handle it, and pathauto is a very popular module.
--------------------
Jake Strawn (@himerus)
himerus.com | Development Geeks
--------------------
Pathauto does not appear to work
himerus. I am already using pathauto for several content types. I want the URL to be:
http://www.domain/billbell
Not
http://www.domain/user/billbell
There appears no way to create a menu default or fallback. "user/%user" is possible, but "%user" is not for the menu as far as I can see.
Thanks.