Download & Extend

Creating fields with default values that users can't edit?

Project:Content Construction Kit (CCK)
Version:4.7.x-1.5-1
Component:General
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi!

I'm working on my first CCK node type: it's a user profile for a community site I run. I've read the excellent CCK Handbook and this tutorial on creating enhanced user profiles using CCK, Usernode, and nodeprofile, but I didn't see this addressed anywhere.

I want to include fields in this new node type that users cannot edit. Example: I'd like to have a field whose default value was [uid], or perhaps site.org/blogs/[uid] to reference a user's weblog on the site.

As far as I can tell, while many of the field types allow me to specify a default value, they also require me to specify a type of interaction (drop-down list, autocomplete text field). But I want to create fields that users aren't interacting with -- because they're intended to automate the publishing of certain data.

Is there a way to do this from within CCK or any associated modules, without resorting to pasting additional php or altering the node.tpl?

With deep respectful bowing towards the vast assembled brainpower of Drupal.org,
Lisa Williams

Comments

#1

Status:active» fixed

What you need here is a "computed field" : http://drupal.org/project/computed_field

#2

Thanks, yched. I'm going to try that out.

#3

A computed field is nice, but it doesn't have the same formatters as the original field.

In my case I'm thinking i.e. about having a view-field with a fixed view and parameter '%nid', that user's shouldn't be able to edit, otherwise they won't see the nodes pointing to this view.
I tried to do this with cck field permissions, but in this case the default value didn't find it's way into the node.

I believe there are already other issues open for this ... just commenting since I don't think a computed field is a complete replacement for this.

#4

Sounds like we could do with a CCK PHP field here actually (although yeah I know what the initial post says). A field that only admins can edit which automatically inserts a php generated value in the node edit/update screen... or is this just horrible?

Also, what happened to the CCK "validated text" module, that created a field which validated against a regexp? I can't find the damn thing anywhere... :p

#5

@NikLP

Sounds like we could do with a CCK PHP field here actually (although yeah I know what the initial post says). A field that only admins can edit which automatically inserts a php generated value in the node edit/update screen... or is this just horrible?

I think cck_field_perms module should give us that, once the problem with the defaults not being written to the node when the editing user isn't allowed to edit the field is taken care of

Also, what happened to the CCK "validated text" module, that created a field which validated against a regexp? I can't find the damn thing anywhere...

I think we need to add some mechanism for user-configurable validation (with 'regexp' being one method) to all fields, and not create a new validated text widget.

PS: I see the issue is for 4.7 when I'm talking about drupal 5 stuff ...

#6

Ray,

Your input is useful anyway. I am on 4.7 today, and my site is hosted by a Drupal hosting provider that provides some managed services, so I can't exactly move to 5 unless I make special arrangements with them.

A side note:

Will CCK and Views make Drupal less friendly to nonprogrammers, because it will encourage developers to create less "finished" modules, with the idea that people will create their own fields, content types, and views?

On a recent Lullabot podcast (the "Deprecated!" episode), I remember hearing one of the guest say that it doesn't matter to end users if a feature is implemented with Views/CCK, and it is better for coders. But it matters a lot to people like me -- site admins who are not programmers.

I worry about this. The two Drupal books I own -- David Mercer's book on Drupal, and Building Online Communities with Drupal, PHPBB, and Wordpress written in part by Drupaler Robert Douglass have contributed so much to my understanding and ability -- but neither one covers CCK. I just looked at the new Pro Drupal Development book, but it's way over my head -- really aimed at programmers who will be coding their own modules. If Drupal is going in the direction of Views/CCK and away from "finished" modules, I pray that someone, somewhere, is already at work on a book that covers these two topics in depth. (Yes, I've read the Handbook. And, for instance, if I could get to a seminar on these topics, I would definitely want to help add to the online documentation here at Drupal.org. Right now, I just don't know enough to be able to contribute).

PS. I'm happy to report that Pro Drupal Development -- four copies -- were available in-store at the Barnes & Noble superstore in Framingham, MA. Not a special order! They have David Mercer and Robert Douglass' books too. I took the liberty of turning the Pro Drupal book face out for better visibility :)

#7

Status:fixed» closed (fixed)
nobody click here