Download & Extend

Could someone please explain how to use this module?

Project:Type-local nids
Version:6.x-1.2
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi,

since this module lacks documentation, a readme.txt or an user interface (as far as I've seen), I kindly ask to clarify, what it does and what it doesn't do; any help from any user of this module is greatly appreciated.

What I am looking for is a CCK field that maintains a unique ID for content types (e.g. an increasing integer value, or some other kind of "counter"). According to the description, the "Type-local nids" comes pretty close to this functionality; however, I haven't yet discovered a way to expose it's values directly to CCK (to display the ID value to the site's users). As far as I have seen, "Type-local nids" offers no CCK field, right?

However, in connection with the Automatic title generation module by fago I'm offered exactly one new Token in the "Replacement patterns" section: [lnid] ("The type-local nid") that can be used to build a new Node title. Another approach seems to utilize CCK computed field to extract the lnid token and write it into a custom-made "counter" CCK field. Is this the recommended way to get unique values into a custom content type, or am I on the wrong track?

Quite a bunch of other people are looking for similar functionality in CCK (see the pointers below); what confuses me completely is that jbrown advertises his module in CCK related thread as an alternative to the "CCK computed field"; the computed field is a CCK field, "type local nids" is not. Or am I missing something?

Thanks for any suggestions & greetings, -asb

Similar threads:

* Auto counter? (Module development) - unresolved
* Computed field in CCK question (Post installation) - Homebrew solution with CCK computed field
* auto-increment unique number within nodes of a specific content-type (CCK issues) - pointer to type local nids module

Comments

#1

I'd like to hear these answers too.

#2

Alternative approach: Computed Field plus the snippet Adding an 'auto_increment' field gives a clean CCK output.

However, this calculated value isn't offered as Token, so we can't get it in the node's title (through Automatic title generation module).

Greetings, -asb

#3

hi there. You are on the right track. I just tries the 6x branch and it appears that token support isn't working. This is a great module and for this purpose I would suggest this over computed field.

My case use....
I have a node type that are parts in a system. I needed to be able to enter parts and have serial numbers assigned to them on the fly. they needed to be sequential, so using the the node id wasn't an option because of other node types int he system. This module was the answer.

to throw another variable in the mix... I needed them to start at 50006. Simply changing the record of the database int he luid_next table for the content type I needed to use this on to 50006 began numbering at the correct number.

I then use the token on the node title, path via autopath and I print it on the node page itself.

Hopefully this helps.

#4

Version:5.x-1.3» 6.x-1.2

see also #349524: lnid not available in presave hook

#5

For me, it is not evident how to use this module, so I'll post here how I made the first part work.

For example, two node types, 'Teacher', and 'Student'. I need to create unique IDs for each person, where the numbering runs as two independent incremental counters.

The first problem is to create automatic path aliases, like:

student/156
teacher/21

For this, you need to install the following modules:

  • Type-local nids
  • Pathauto
  • Token

Then, you have to set-up your aliases in 'admin/build/path/pathauto', under the section 'Node path settings':

Pattern for all Student paths:
student/[lnid]
Pattern for all Teacher paths:
teacher/[lnid]

This solves the first part for me, but I still have to find out the second part: How do I use the lnid inside a page template?

#6

I just found out how to print the lnid in a template. As usual, it was really trivial. Just put the following code wherever you need, inside your node.tpl.php:

   <?php print $node->lnid; ?>

#7

That's ok if you want to mess with templates, but why can't it be exposed as a field that one can choose to display or not via the usual means?

I'm using a calculated field because we have an odd situation where I need to be able to encode large numbers into only 3 characters (I'm converting to alpha-only base 26), but for troubleshooting purposes it would be very helpful to be able to display the lnid on the page.

#8

This module needs to be implemented as a CCK field and then you'll get a lot of stuff for free.

#9

This thread is getting stale; this is now implemented very nicely in CCK through the "Serial" module.

After trying a Type Local NID solution and discovering it won't work with Auto Nodetitle ([lnid] is not available by the time the presave function in Auto Nodetitle is run), I switched to the Serial module, and highly recommend it. Worked like a charm.

I added a serial field (e.g. "MySerialFieldName") to my content type. Then I used the CCK token [field_MySerialFieldName-id] in the PathAuto settings to get it into the URL. Then I got it into Auto Nodetitle using the following snippet (with "Evaluate PHP" turned on):

<?php
 
global $form_values;
 
$title = 'This is a new node written by '. $form_values['field_MySerialFieldName'];
  return
$title;
?>

Voila! Per content type serial numbers you can include in Pathauto and Auto Nodetitle. Hopefully this will save someone else some time or help jog new ideas for your own use case.

#10

Thanks Fenwick - the Serial module (http://drupal.org/project/serial) works perfectly and is what others have said should be done - implemented as a CCK field.