I'm looking for a solution for automatic item number creation that will auto-create a reference number/code for any posted article, whatever the Node type. The purpose being that for any posted article (any Node type) that is created & posted by an author (with permission Roles authorised to post content) will have an item reference which can be traced throughout all aspects of workflow (including any Ticket Support document output - printer etc). This could quite simply be a standard item number as of that used on eBay (string of numbers) or similar used in organisational-wide portal. It might be for use in a local sales listing references (as in Gumtree), a vehicle listing platform (autotrader.co.uk) or simply to give a volumous document based content site a posting reference (internal intranet/external netsite), which for example, a 3rd party reader can jot down on paper, (email, cut and paste in Notes etc) and come back later and do a simple 'search' with the reference number, but not a 'purchase order' reference (as in Ubercart), purely for article reference purposes.

I'm not looking for anything tremendous (I'm not a PHPer (yet!) and I know this is more of a backend SQL DB but being more a Drupal 'plumber'/experimentalist I'm looking for simple solution for now that can be built upon later; something that Barcode module can also take advantage of and I can use in future projects of informational DataBases. Does anyone know of such a suitable solution/module for D7?

Any comments or How-tos welcome. Thanks.

  • Just a final note. I installed & used the UUID module and edited my Content Node (Panel template Variant) to include the UUID, and Voila! a system generated number, most suitable as an 'ultimate' system ID for the said content was included and shown in the content. This is EXCELLENT and provides just the short of thing I wanted, albeit a little long, it is most suitable. Now I just need to turn it into a QR using Barcode. Thanks again to everyone's comments and advice. – Paul B Oct 11 '12 at 10:24

Option 1. You can use an existing node ID (NID).

Each node already has an ID and can be accessed via /node/[nid], [nid] being the ID of the node. Or you can generate a path alias by inserting <?php print l('link', 'node/' . $nid); ?>, $nid being the ID of the node. To retrieve NID of a current node, insert <?php print $node->nid; ?> into node.tpl.php.

Option 2. You can also use the combination of Automatic Nodetitles and Token module. This will allow you to automatically generate node title with the values from the Token.

Once the modules are installed, go to Structure -> Content Types, click on Edit, next to your content type. While on the Automatic title generation tab, select to Automatically generate the title and hide the title field, and in Pattern for the title, post a token from the options below; see the image below. There are many options with tokens, such as Unix timestamp (my favorite), random numbers and more.

enter image description here


For a truly random serial number, instead of using the Token module, I'd suggest using uniquid(); it generates a 13 character long random serial, no duplicates. This would be my choice. To do so, put this into "Pattern for the title" field, don't forget to check "Evaluate PHP in pattern":

<?php echo uniqid(); ?>

If you have spare time, there is also a Serial Field and Universally Unique IDentifier module, which also generate unique values.

|improve this answer|||||
  • That's very interesting and helpful, thank you Timofey for your response. I'll check it out and see what I can do with your helpful suggestions. – Paul B Oct 9 '12 at 21:16
  • Further to timofey's suggestion, I'll use drupal.org/project/auto_entitylabel for my Drupal v7.15 and see if it helps generate ID references suitable for Article Content (node). I quite like the idea of the 'Random' option above. – Paul B Oct 9 '12 at 21:23
  • Sorry, but just to clarify that this is the correct route, the created Pattern will be capable of being written to a field associated to the said Article Node so that in future any user can search for an article based on a ref (ie: pancake recipe titled "10 Ways To Make Quick Pancakes": Ref ID: 24356578 or PANC-QK-10-2012). I know libraries use a standard format but I'm not looking for any international standard, but something that works similar, or like an Amazon.com product/SKU. – Paul B Oct 9 '12 at 21:43
  • Yes, if you add a field or use an existing field, with a generated number, it will be searchable within Drupal. Just don't forget to run Cron, to index search, before you try searching. – timofey.com Oct 10 '12 at 0:07
  • Also, I've added a bit more info on my post. You might be better off using uniqid() instead of tokens – timofey.com Oct 10 '12 at 0:08

Checkout this module Universally Unique IDentifier . It may suit your needs.

|improve this answer|||||
  • Thank you that is very helpful, I will look to UUID module today. – Paul B Oct 10 '12 at 9:06
  • It's already been mentioned in the previous answer. – timofey.com Oct 10 '12 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.