Joomla 1.5 Extended Registration
Update: There’s a whole new series on customizing Joomla, the tutorial on how to create a Joomla component from scratch might be especially interesting in relation to this tutorial.
Source can be found here.
What if you need something more than the default registration form in Joomla? Like for instance adding mobile phone validation, zip code and many more custom fields. Then you could make your own component that extends the functionality of the normal default user component and that is what this tutorial is all about.
Quick how to:
1.) Start with copying the current com_user folder and name it com_extendeduser, edit the xml description file to reflect the changes.
2.) Make an sql file with the sql needed to create the new table jos_extuser. Zip it up and install in the Joomla backend.
3.) It’s time to start coding. We start by making an extension to JTable in the models folder of our new component, we call the class TableExtUser and it should contain member variables that match the field names in the database exactly. All except the password which we call $_password. Next we add some methods, many are extensions to the JTable.
4.) Next we create some display functions to make the view file look as clean as possible. It will be a kind of poor man’s Smarty. Anyway we create these utility functions in the view.html.php file in the register folder.
5.) Now we can edit the default.php file in register/tmpl/ and use our newly created display functions. We also create some new views, for instance a form where the user is prompted to enter a valid code which she should have gotten as an SMS to her phone.
6.) Then we modify the controller in controller.php. This is done mainly by working with the register_save() function in order to save to our new extended user table as well as to the default user table. We also add a few functions and change in some more places. To see everything you could use kdiff and examine how the file in our new component differs from the equivalent in com_user.
7.) Finally we create a new login module called mod_extlogin which basically is just a tiny mod of mod_login in order to route some stuff to our extuser component instead of the normal user component.
8.) Now you are ready to use your new fancy registration form while at the same time letting the out of the box code do as much as it can. A big example is email validation which we just left to the default logic of Joomla.
9.) Optional: Drop necessary language files in the com_extendeduser folder.
I hope this will help all you people who are thinking about charging people for high quality content through their mobile phones.
Related Posts
Tags: Joomla, joomla component, PHP