Hello! What about working D7 port?
I just found that hooks that module is using are incorrect.
So, this code provide lnid token to token list, but other function's working I can't check.

Was:

/**
 * Implement hook_token_list() .
 */
function type_local_nids_token_list($type = 'all') {
  if($type == 'node' || $type == 'all') {
    $tokens['node']['lnid'] = t("The type-local nid.");
    return $tokens;
  }
}

Should be:

/**
 * Implement hook_token_info().
  */
function type_local_nids_token_info() {
  $info['tokens']['node']['lnid'] = array(
    'name' => t('The type-local nid.'),
    'description' => t('The type-local nid description.'),
  );
  return $info;
}

Was:

/**
 * Implement hook_token_values() .
 */
function type_local_nids_token_values($type, $object = NULL, $options = array()) {
  if($type == 'node') {
    $tokens['lnid'] = $object->lnid;
    return $tokens;
  }
}

Should be something like this:

/**
 * Implement hook_tokens().
  */
function type_local_nids_tokens($type, $tokens, $data = array(), $options = array()) {
  $replacements = array();
  if ($type == 'node' && !empty($data['node'])) {
    if (isset($tokens['lnid'])) {
      $original = $tokens['lnid'];
      $replacements[$original] = $data->lnid;
    }
  }
  return $replacements;
}

I think it need some minutes to make module port working.

Or maybe [node:content-type:node-count] token will work like Type local nids module?#1037312: How [node:content-type:node-count] token works?

Comments

tommychris’s picture

A little change in the token part - adter this change, I'm able to use the [node:lnid] token to use in auto nodetitle

/**
 * Implement hook_tokens().
  */
function type_local_nids_tokens($type, $tokens, $data = array(), $options = array()) {
  $replacements = array();
  if ($type == 'node' && !empty($data['node'])) {
    if (isset($tokens['lnid'])) {
      $original = $tokens['lnid'];
      if (isset($data->lnid)) // Original code
        $replacements[$original] = $data->lnid;
      else if (isset($data['node']->lnid))  // At node update, auto-nodetitle
        $replacements[$original] = $data['node']->lnid;
      else  // If the token is not available, I like to see some text, not an error
        $replacements[$original] = t('Please re-save the node!');
      
    }
  }
  return $replacements;
}

To use the token [node:lnid] in autotitle, go to this thread: #349524: lnid not available in presave hook

JohnnyX’s picture

Hello,

I'm searching for a module to set unique numbers to content types (like unique ticket numbers). This module seems to be the solution but is the D7 version atomic? I have seen an open D6 issue and not sure if fixed at D7 dev module...

Best regards

tommychris’s picture

No, it's not. Serial field module is atomic, but it doesn't have a proper D7 release. :/

tommychris’s picture

Status: Active » Needs review