Extend the User Parameters
Posted: Tue Sep 18, 2007 5:07 am
On Sunday, I noticed this comment in the SVN Updates:
Intrigued, I started looking at custom parameters for Users. It appears like we can add our own custom parameters for User and have those stored in #__users table within the params column.
1. It appears we could update the administrator/components/com_users/models/user.xml file to add new param lines.
For example: name="test" type="test" default="" label="Test" description="Test for this User" />
With this ability, we could add User Parameters, like:
Example 1: Display Profile
Example 2: Gender
See attached file that to be placed in libraries/joomla/html/parameter/element/gender.php
Example 3: User Category
See attached file that to be placed in libraries/joomla/html/parameter/element/usercategory.php
These parameters are automatically loaded into the Backend User Manager and the Front End Your Details forms, and updated within the database for changes.
It appears that joomla/user/user and joomla.html.parameter load $params with the User Parameters.
*****
Questions:
If we create an extension and desire additional user parameters (fields) is it intended that we add to administrator/components/com_users/models/user.xml, or are we to create another user.xml file, at a new location, to append in custom user parameters?
If we are to change the administrator/components/com_users/models/user.xml as part of an extension installation, how can we "tell" the installation to automatically add custom parameters and remove these parameters upon de-install of the extension?
If we are to create new "data access" programs for the type parameter, how do we "tell" the installation process to place the new "type" file within the libraries/joomla/html/parameter/element/ (assuming the new file has been created)?
Again, very cool design and hats off to the developers. If someone has ideas on these questions - and can tell me if my thinking on User Parameters is correct or not, I would appreciate the guidance.
Amy
SVN 8930 09/16/2007 Jinx - Added a $path parameter to JUser::getParameters. This change allows to easily extend the user parameters and allow the use of a custom parameters xml file for each usertype.
Intrigued, I started looking at custom parameters for Users. It appears like we can add our own custom parameters for User and have those stored in #__users table within the params column.
1. It appears we could update the administrator/components/com_users/models/user.xml file to add new param lines.
For example: name="test" type="test" default="" label="Test" description="Test for this User" />
- name - Name of parameter; must be unique
- type - valid choices for "type" are identified by the listing of files in the libraries/joomla/html/parameter/element. Created "Gender" and "UserCategory" example for creating new "type."
- default - default value when not initialized for user
- label - Value displayed in interface for user
- description - when mouse is hovered over label, this values is provided
With this ability, we could add User Parameters, like:
Example 1: Display Profile
Code: Select all
<param name="displayprofile" type="radio" default="1" label="Display Profile" description="Dsplay private profile information.">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
Example 2: Gender
Code: Select all
<param name="gender" type="gender" default="" label="Gender" description="Gender for this User" />
See attached file that to be placed in libraries/joomla/html/parameter/element/gender.php
Example 3: User Category
Code: Select all
<param name="usercategory" type="usercategory" default="" label="User Category" description="Category for this User" />
See attached file that to be placed in libraries/joomla/html/parameter/element/usercategory.php
These parameters are automatically loaded into the Backend User Manager and the Front End Your Details forms, and updated within the database for changes.
It appears that joomla/user/user and joomla.html.parameter load $params with the User Parameters.
*****
Questions:
If we create an extension and desire additional user parameters (fields) is it intended that we add to administrator/components/com_users/models/user.xml, or are we to create another user.xml file, at a new location, to append in custom user parameters?
If we are to change the administrator/components/com_users/models/user.xml as part of an extension installation, how can we "tell" the installation to automatically add custom parameters and remove these parameters upon de-install of the extension?
If we are to create new "data access" programs for the type parameter, how do we "tell" the installation process to place the new "type" file within the libraries/joomla/html/parameter/element/ (assuming the new file has been created)?
Again, very cool design and hats off to the developers. If someone has ideas on these questions - and can tell me if my thinking on User Parameters is correct or not, I would appreciate the guidance.
Amy