Quick fix for arranging CCK fields, when a module defined field gets in your way

13 Sep 2011

Joris Snoek
Digital Consultant
+31 (0)20 - 261 14 99

Ever experienced the following issue in configuring CCK fields:
you drag-and-drop your field in the right position on admin/content/node-type/%/fields.

But a when you want to add a node of configured content type:

a module or system gets in your way when you look at the node/add form in your backend. It puts itself between two fields where you dont want it.

Hmm, that can be kind of a difficult to don't get all technical, but well: this is caused by the 'weight' a CCK field gets 'under water in database' when you drag-and-drop it, in admin/content/node-type/%/fields.

Weights in Drupal

This weight can be for example: -10, -8, 0, 1 or 4 and that's the way it's stored in Drupal's precious database.

Now here is the pain: a module can also define a weight, and this is done by this number. So for example: the notification field get a '3' but this is no field you can drag-and-drop in admin/content/node-type/%/fields

Change weight your CCK fields

I used the magnificent Drupal intranet distribution Open Atrium for this example
So when you add you own fields, Drupal may give your fields weights, based on your dragging and dropping. So for instance:

  • Title field gets '0'
  • Date field get '1' (field defined by you in CCK)
  • Country gets '2' (field defined by you in CCK)
  • State gets '3' (field defined by you in CCK)
  • City get '4' (field defined by you in CCK)

When turning on 'notifications'

So here's what happens when you also have (for example) the 'notifications' module turned on: that one will also be places in '3', so it in your node/add screen the notifications gets between your State and City field!

That's not very usable.. I'm not down with that..

But, eureka! Quick solution

Well, you can write a module and hook_form_alter() your way around, no problem.
BUT, here is a faster and less technical way:
Turn off javascript in Firefox, with help of web developer toolbar.
That way the drag-and-drop buttons will disappear and Drupal will place textfield where you can fill in the weight number all by your self!
See screentshot, that's also downloadable underneath this post.

That's all. Lot of words, for a seem-able minor issue.

Ow and: please don't mind the field names here, this is a test install. English and Dutch fields are defined: that's not very handy on a production system :-)

Feedback or Questions about the CCK or open atrium module in Drupal?

Please hit me on Twitter for all your feedback, and any other issue!
But also http://www.drupal.org and http://www.openatrium.com of course.

Comments

Nóg meer
kennis nodig?

Check ons ons blog archief >