Closed (fixed)
Project:
Serial Field
Version:
7.x-1.2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
9 Oct 2009 at 17:31 UTC
Updated:
31 Jul 2013 at 03:29 UTC
Jump to comment: Most recent
Very useful module. Would be nice to allow a starting number, like 1,000.
Also, if I use this id in a token for auto node title, how does the node get saved?
In order to do this atomically I'm assuming the id is assigned at node save.
If so would the auto node title module assign this id properly at save?
When I added this field to an existing content type I got a zillion of this error, I think one for each of the existing nodes:
user warning: Duplicate entry '353' for key 2 query: INSERT INTO serial_condo_building_field_serial_id (nid) VALUES(353) in /usr/local/www/apache22/data/sites/all/modules/serial/serial.inc on line 89.
Comments
Comment #1
druplicate commentedHow is this module different from the Type Local NID module other than being a CCK field?
Per this issue: http://drupal.org/node/398116
Is it truly atomic, ie does it mimic the way Drupal assigns NIDs?
Comment #2
kirsh commented> Would be nice to allow a starting number, like 1,000.
Might be supported in future versions. Meanwhile you may try using ComputedField + Serial.
> Also, if I use this id in a token for auto node title, how does the node get saved?
I didn't try it with node title, but a serial field is not different than any other field - save is managed by CCK.
> When I added this field to an existing content type I got a zillion of this error
This might be a bug. It didn't happen when I added a serial field to an existing content type.
> How is this module different from the Type Local NID module other than being a CCK field?
The atomic allocation.
> Is it truly atomic, ie does it mimic the way Drupal assigns NIDs?
Yes, it is atomic. Both Drupal nid and Serial field (but not Type Local nids) use an underlying serial database field.
Comment #3
druplicate commentedThanks.
I was curious about how the CCK node gets saved because of all this discussion:
http://drupal.org/node/194197
Seems like it's a big deal and I wanted to know how or if this module addresses it, especially with respect to tokens.
Comment #4
kirsh commentedComment #5
Architeck commentedI'll second the request "Would be nice to allow a starting number, like 1,000"
Can you provide an example using ComputedField + Serial?
Thanks, Great module, I have also applied the patch from http://drupal.org/node/606250#comment-2528212 it's a nice little addition.
Comment #6
kirsh commentedInstall ComputedField. First create a serial field and then a computed field.
Set the computed code:
$node_field[0]['value'] = $node->field_serial[0]['value'] + 1000;
where field_serial is the internal name of the serial field.
You will have to adjust the code if you are using the prefix/suffix patch.
But actually, if you are using a computed field - you do not need that patch, you can add the suffix/prefix here.
Make sure "Store using the database settings below" is checked (otherwise the computed field is not accessible in Views) and set the data type as int.
If you already have nodes with serial values you will have to save them again to get a computed field value.
Comment #7
nicholas.alipaz commentedActually, even easier than adding an additional field to the database, and of course this depends on how one would like to use these fields. You can do something like the following using cck custom formatters (just import this definition and enable for your field's display setting):
--
Los Angeles Web Design and development for Drupal.
Comment #8
Rix-1 commentedI set the code to:
$node_field[0]['value'] = $node->field_serial[0]['value'] + 1000;
and changed 'field_serial' to my internal field name 'field_photo_ref' so my code is:
$node_field[0]['value'] = $node->field_photo_ref[0]['value'] + 1000;
but i get the following error:
* Notice: Undefined variable: node in eval() (line 1 of /..../sites/all/modules/computed_field/computed_field.module(439) : eval()'d code).
* Notice: Trying to get property of non-object in eval() (line 1 of /..../sites/all/modules/computed_field/computed_field.module(439) : eval()'d code).
What am I doing wrong?
[Drupal 7]
Comment #9
Rix-1 commentedAlso, does this mean that everytime I save it, it will add 1,000 to the serial field? So the serial number will change every time I update the page? :o(
Comment #10
mel-miller commented@rix
Did you ever find a solution to those errors?
Comment #11
Rix-1 commentedNope - abandoned the project.
Comment #12
alexander.sibert commentedI search a solution for my URLs attachment. I installed Serial and Computed field. Now i want to produce following number and use it in URLs via Token.
http://domain.tld/000014
http://domain.tld/000015
http://domain.tld/000114
http://domain.tld/002214
You see what i mean.
Comment #13
imunk commentedits a great module but since it has'nt a prefix or sufix number in the module it not really usefull, but it will be a great module if you put the starting or ending number on it..
Comment #14
seanenroute commentedHi, for those using D7 the Computed code to add a 1000 (to make it a 4 digit code) is:
$entity_field[0]['value'] = $entity->field_serial[LANGUAGE_NONE][0]['value'] + 1000;