Custom fields

14 views
Skip to first unread message

Arjen

unread,
Jan 10, 2018, 4:53:30 AM1/10/18
to dotCMS User Group
Hi,

Does anybody know if it's possible to add custom fields or properties to default dotcms objects?
For example, if I wanted to add a certain date field (join date) to the user properties would that be possible?

I guess ideally I'd be able to add these from within an osgi plugin, but any option would be great.

Thanks
Arjen

Nathan Keiter

unread,
Jan 10, 2018, 9:28:30 AM1/10/18
to dot...@googlegroups.com

I wouldn’t mess with the user_ or user_proxy objects.

 

You could create a content type to store meta-data, keyed on username or userid.

 

Then you could pull the content for display somewhere.

 

You’d have to override or intercept the account registration process to save to your content type the extra fields.

 

Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/741b8d25-162b-4894-9b30-ed96f1371d1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Michael Thomas

unread,
Jan 10, 2018, 10:38:39 AM1/10/18
to dotCMS User Group
You can add fields to any object which has a Content Type.  This includes Sites, Page Assets, File Assets, and in 4.2 it also includes Vanity URLs and Language variables.

But you can't easily add fields or properties to any object which is not content.  This includes Users and Roles, Templates, Containers, Menu Links, Rules, Categories, and Workflows.

You might be able to add properties to some of these via a plugin, but I agree with Nathan that it's probably not a good idea to add properties to any of the permission objects (Users and Roles).

Here's a couple other ways you may be able to do this without touching the permissions tables:
  • Linked Content Type: As Nathan said, you could create a separate content type to link to the user ID.
    • This would obviously require some coding and management, but you could make this semi-seamless by updating the UI code to display this on the Users screen without touching the users table in the DB.
  • Use an Existing Field: Hijack one of the other purely informational fields in the existing Users screen (like the Facebook ID, Open ID, etc. fields under the "Additional Info" tab) to display the information you want to keep for each user.
    • Changing the UI to display a different label for one of these (and maybe format the data as a date) would be fairly simple.

Hope it helps.

Arjen

unread,
Jan 10, 2018, 10:53:07 AM1/10/18
to dotCMS User Group
Thank you both very much.

I was hoping to be able to avoid this but I think I'll just have to 'hijack' an exiting field for this purpose, but it would have been nice to be able to customise them instead.

Thanks anyway.

Arjen
Reply all
Reply to author
Forward
0 new messages