any better way to add new attributes for users?

czhu3

Joined: 2005-09-02
Posts: 6
Posted: Fri, 2005-09-09 10:21

I'm trying to add some more details like "phone, address..." for the users. I've manually changed the database for the user and other files including the register module and files within the core module like GalleryUser.class etc.
But failed...
Is there other way to do that?

Thx!!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-09 11:30

you'd have to create a new module which extends the GalleryUser class and registers its implementation with the factory.
maybe some other changes are needed too.

i see that adding new attributes to the gallery users is a pretty popular feature request.
so i envision something like custom fields just for gallery users, such that you can add new attributes with a GUI rather than with a lot of new code.

but this is not even planned...

 
czhu3

Joined: 2005-09-02
Posts: 6
Posted: Fri, 2005-09-09 11:34

Thanks, Valiant!!
So how can I register the implementation with the factory? 'cause not really clear about that aspect.
Also are there any docs that I can read for that?

:roll:

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-09-09 11:52

most of the important G2 functionality / API is listed in
modules/core/classes/GalleryCoreApi.class

you can call any of these functions with GalleryCoreApi::functionName(arguments);
above each function, there are some comments which explain which parameters are expected (@param) and what it returns (@ret).

in this class, there are also the factory registration functions.

what i do when coding for G2:
first see if any other module / file does almost the same or a part of what i need to do. then copy the fragment of code. e.g. you can copy the factory registration code from pretty much every modules/modulename/module.inc file see function performFactoryRegistration.
e.g. module/comments/module.inc registers it's implementation of the comment entity or modules/register/module.inc registers the PendingUser entity which also extends the GalleryUser.

 
czhu3

Joined: 2005-09-02
Posts: 6
Posted: Fri, 2005-09-09 11:54

Great, thanks!

i'll try that!!