AmiWiki:Coordination/Drupal things

From AMI@Work Communities Wiki

Contents

[edit] Skin

[edit] Configuration

For site-wide authentication, see AmiWiki:Coordination/Drupal auth.

[edit] Pretty URLs

Enable "clean URLs" as described in http://drupal.org/node/15365.

[edit] Aliases

The following code should be added to the config file in order to support aliases in the form ~username -> blog/123:

function conf_url_rewrite($path, $mode = 'incoming') {
  if ($mode == 'incoming') { // URL coming from a client
    if ($path{0} == '~') {
      $u = db_fetch_object(db_query("SELECT uid FROM {users} WHERE name = '%s'", check_plain(substr($path, 1))));
      if ($u)
        $path = "blog/$u->uid";
    }
  }
  elseif ($mode == 'outgoing') { // URL going out to a client
    if (substr($path, 0, 5) == 'blog/' and strspn(substr($path, 5), '0123456789') == strlen(substr($path, 5))) {
      $u = db_fetch_object(db_query("SELECT name FROM {users} WHERE uid = '%s'", check_plain(substr($path, 5))));
      if ($u)
        $path = "~$u->name";
    }
  }
  return $path;
}
Personal tools
community tools