t('path'), 'description' => t('Path Aliases: This is an admin setting only. Enable it for path aliasing.'), 'include' => 'path', 'prefix' => t(''), 'suffix' => t('articles'), 'weight' => -3, 'form' => FALSE, 'label' => t('Add Tagged Content'), 'help' => t('You can track content by keyword category. Type a keyword in the search box to find the matching category, or choose one of the example links.'), 'search' => TRUE, 'threshold' => PATH_THRESHOLD ); if ($get_options) { $type['options'] = mysite_type_path_options(); } return $type; } } /** * Set the options for this type */ function mysite_type_path_options() { $options = array(); return $options; } /** * Settings for this type */ function mysite_type_path_settings() { if (module_exists('path')) { return drupal_get_form('mysite_type_path_settings_form', $vocabularies); } else { return t('The taxonomy module is not active or there are no vocabularies. These features cannot be used.'); } } /** * FormsAPI for mysite_type_path_settings */ function mysite_type_path_settings_form() { $form['mysite_path']['mysite_path_enabled'] = array( '#type' => 'radios', '#title' => t('Automatically create path aliases'), '#default_value' => variable_get('mysite_path_enabled', 0), '#options' => array(0 => t('No'), 1 => t('Yes')), '#required' => FALSE, '#description' => t('If enabled, you may set the path alias rules below') ); $options = array(0 => t('mysite/username'), 1 => t('mysite/username/view')); $form['mysite_path']['mysite_path_rules'] = array( '#type' => 'radios', '#title' => t('Path creation rules'), '#default_value' => variable_get('mysite_path_rules', 0), '#options' => $options, '#required' => FALSE, '#description' => t('Select the path alias rules that you prefer.') ); return system_settings_form($form); } /** * Implementation of mysite_type_{name}_update * * When the user updates a MySite page, this will creata a path alias * */ function mysite_type_path_update($uid) { if (variable_get('mysite_path_enabled', 0) == 1) { $alias = variable_get('mysite_path_rules', 0); $sql = "SELECT uid, name FROM {users} WHERE uid = %d"; $result = db_query($sql, $uid); $myuser = db_fetch_object($result); switch ($alias) { case 0: $path = "mysite/$myuser->name"; break; case 1: $path = "mysite/$myuser->name/view"; break; } $check = drupal_lookup_path('alias', $path); if ($check == FALSE) { path_set_alias("mysite/$myuser->uid/view", $path); } } return; }