Hi,

i'm experimenting with the pathauto module, and I wonder what would be needed to use the article citekey in the path e.g. /publication/[Citekey] for each biblio entry. There are already some fields available, such as [biblio_year], [biblio_authors], but the citekey is not available. Any hints?

Thanks,

Sebastien

Comments

rjerome’s picture

Shouldn't be a problem, just modify the biblio_token_list() and biblio_token_values() functions in the biblio.module file, and add a line in each function similar to the biblio_year entry like this...

function biblio_token_list($type = 'all') {
  if ($type == 'node') {
    $tokens['node']['biblio_year']      = t("Biblio: Publication year");
    $tokens['node']['biblio_citekey']      = t("Biblio: Citation key");
    $tokens['node']['biblio_authors']   = t("Biblio: Authors");
    $tokens['node']['biblio_type_id']   = t("Biblio: Type ID (e.g.: 100)");
    $tokens['node']['biblio_type']      = t("Biblio: Type Name (e.g.: book)");
    return $tokens;
  }
}

/**
 * Implementation of hook_token_values() for og specific tokens
 */
function biblio_token_values($type, $object = NULL) {
  switch ($type) {
    case 'node':
      if ($object->type == "biblio") {
        $type = db_result(db_query('SELECT name FROM {biblio_types} as t WHERE t.tid = %d',$object -> biblio_type));
        #$title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $gid));
        $values['biblio_year'] = check_plain($object->biblio_year);
        $values['biblio_citekey'] = check_plain($object->biblio_citekey);
        $values['biblio_authors'] = check_plain($object->biblio_contributors[1][0][lastname]);
        $values['biblio_type_id'] = check_plain($object->biblio_type);
        $values['biblio_type'] = check_plain($type);
        return $values;
      }
      break;
  }

  // No group info found. Return defaults.
  $values['biblio_year'] = '';
  $values['biblio_citekey'] = '';
  $values['biblio_authors'] = '';
  $values['biblio_type_id'] = '';
  $values['biblio_type'] = '';
  return $values;
}
rjerome’s picture

Shouldn't be a problem, just modify the biblio_token_list() and biblio_token_values() functions in the biblio.module file, and add a line in each function similar to the biblio_year entry like this...

function biblio_token_list($type = 'all') {
  if ($type == 'node') {
    $tokens['node']['biblio_year']      = t("Biblio: Publication year");
    $tokens['node']['biblio_citekey']      = t("Biblio: Citation key");
    $tokens['node']['biblio_authors']   = t("Biblio: Authors");
    $tokens['node']['biblio_type_id']   = t("Biblio: Type ID (e.g.: 100)");
    $tokens['node']['biblio_type']      = t("Biblio: Type Name (e.g.: book)");
    return $tokens;
  }
}

/**
 * Implementation of hook_token_values() for og specific tokens
 */
function biblio_token_values($type, $object = NULL) {
  switch ($type) {
    case 'node':
      if ($object->type == "biblio") {
        $type = db_result(db_query('SELECT name FROM {biblio_types} as t WHERE t.tid = %d',$object -> biblio_type));
        #$title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $gid));
        $values['biblio_year'] = check_plain($object->biblio_year);
        $values['biblio_citekey'] = check_plain($object->biblio_citekey);
        $values['biblio_authors'] = check_plain($object->biblio_contributors[1][0][lastname]);
        $values['biblio_type_id'] = check_plain($object->biblio_type);
        $values['biblio_type'] = check_plain($type);
        return $values;
      }
      break;
  }

  // No group info found. Return defaults.
  $values['biblio_year'] = '';
  $values['biblio_citekey'] = '';
  $values['biblio_authors'] = '';
  $values['biblio_type_id'] = '';
  $values['biblio_type'] = '';
  return $values;
}
sebos69’s picture

Works great! Thanks Ron!

do you need a patch against HEAD or can you add it?

rjerome’s picture

I'll add it, no need for a patch.

bekasu’s picture

Status: Active » Closed (fixed)

marking issued closed.
bekasu