Does anyone have a test bit of code for creating a custom user setting, that's say a textfield in MODx revo?
Just so I know then how to do such a task.
Thanks
-
☆ A M B ☆
- 24,524 Posts
Is this for the front-end, or a Custom Manager page in the Manager?
I don't quite understand what you mean sottwell...
If you go into the manager, and update a user, there is a tab called "Settings" and from there you can "Create a new setting".
I would like to know how to do that - via the API.
This is not easy via the API. Creating System Settings via the API has specific requirements that must be met prior to the Setting being created. The primary concern is the Lexicon. A Setting in MODx requires two entries in the Lexicon before it will be accessible. That said, it will be readable, but it will not be writable. Then, it requires you to refresh the cache.
Is the UserSetting an override for an already existent SystemSetting or ContextSetting?
-
☆ A M B ☆
- 24,524 Posts
He's talking about custom USER settings, not system settings. It's the user_settings table.
My response was to determine whether this field will appear in a form on the front-end, for example a user registration form, or if it's to be part of a custom Manager page.
User Settings, Context Settings and System Settings ultimately mean the same thing. A User Setting overrides a Context Setting or System Setting, if present. Context Settings override System Settings if present. They all have similar requirements.
Further, unless specified, they use the same Lexicon keys, etc... I stand by my previous statements. If you are not overriding a System Setting, you must have the Lexicon keys in place... Then you must also clear the cache.
-
☆ A M B ☆
- 24,524 Posts
Hm. Looks like I've been laboring under a misapprehension of what the user_settings table was for even in Evo for a long time! I always thought it was just a table for storing user-defined extended fields.
Well, even so, it still makes a difference whether this would be in a custom Manager page or on the front-end.
[ed. note: sottwell last edited this post 14 years ago.]
The code is no different, you are correct. I think the confusion that susan was having is that she was thinking of extended fields, not user settings which are totally different.