I'm developing a site for a charity which teaches people with disabilities how to use computers (www.ucandoit.org.uk). Two of the user roles on the site are going to be "learner" and "tutor". I want to have a field in the user profile for each learner which is a drop-down list containing a list of tutors, so that the administrators who create the students' account can allocate each student a tutor.
I've tried to do this using a variety of modules (mainly content_profile; see http://drupal.org/node/328575 and other posts I've made) but none of them has quite worked. So now I'm thinking, should I just go ahead and write a module which will add a field to a user profile which can display nodes or user profiles generated by a view?
I have never written a module before. I'm able to put Drupal sites together and theme them, to the point or adding and removing variables to and from .tpl.php files and changing the CSS. I've never overridden a function or used hook_form_alter or anything.
So, how difficult would it be for me to start putting this module together? And what do you think I need to learn?
Comments
If you have good PHP and DB
If you have good PHP and DB experience, it isn't hard at all and it doesn't have to be as elaborate as some of the cool modules out there.
Off the top of my head, I think you could use a _form_alter hook to modify the user profile form to add in an extra field and upon submission, store the value in the separate table. I think you can try that... not 100% sure. Only way to find out is to try it out!
Check the Module Developer's Guide to get an idea: http://drupal.org/node/508
The Book "Pro Drupal Development" 1st and 2nd edition are pretty good books to learn how to build your own modules too.
Check out Node Profile module...
Hi There -
You might want to check out the Node Profile module. http://drupal.org/node/65387
It allows you to use CCK fields in the profile.
Also check out the Bio Module: http://drupal.org/project/bio
Either one may do what you're looking for.
Thanks - but neither of
Thanks - but neither of those modules are available in D6, which I want to use so I can use Views2. Good suggestion though - this would be perfect if I was using D5!
content_profile
content_profile is their D6 successor
--Zivtech--
I'm afraid that
I'm afraid that content_profile.module doesn't appear to do what I need it to do. I need a drop-down box to appear in the user profile creation screen, and content_profile seems to "pin" a node to a user account. It probably sounds really picky, but to keep to workflow straight I do need eveything to be done on the one form.
Thanks for your advice. I
Thanks for your advice. I have Pro Drupal Development, and I'm now reading Beginning PHP & MySQL, also by Apress. I think I'm going to get someone else to develop this for us (someone has already contacted me via my contact form) but it would be good to know this stuff for the future.
_form_alter has been mentioned before when I've asked about this - I think it might be the way to go (now I just need to find out what it means :-) )
I've finally got round to
I've finally got round to creating my first custom module which does the above: anyone who wants the code should contact me for the latest version.
For the record I found that getting a basic understanding of PHP and MySQL was a prerequisite. To get the PHP knowledge I read the first 200 pages of the Apress book "Beginning PHP and MySQL: Novice to Professional - 3rd Edition" by W. Jason Gilmore (http://www.beginningphpandmysql.com/), which covered everything up to and including basic object-oriented PHP. I then scanned the chapters on writing SQL queries to create, delete and edit tables, but this was really straight forward.
I then read through the first couple of chapters of "Pro Drupal Development - 2nd Edition" by John K. VanDyk (http://www.drupalbook.com/). It's an incredible book overall - one of the best technical books I've ever read. The first couple of chapters took me through building a simple module. Since my module is all about user accounts, I then read the chapter on working with hook_user and after a few days of occasionally frustrating learning my module was ready to go.
All in all the experience has been really positive and I'd definitely recommend anyone who is familiar with Drupal and wondering whether they should take the plunge with module development to give it a go.