Client-Biodata simple custom module
Why?
This is the module I made when applying to sapua.com (for pre-interview test), gave me the use case and design for my first custom module.
I'll post it's description later. Too sleepy right now.
Well, I was going to post the images related to the requirements, then again, that might raise privacy issue since those came with an email that was sent to my personal mail.
Anyway, this is the summary:
- Create 3 menus, and show them in "navigation" menu block.
- 1st menu exposes a form, where you can input name, place and date of birth.
- Birth-place uses radio buttons with predefined options.
- Birth-date will popup calendar select dialog.
- 2nd menu display a table of name and age.
- 3rd menu shows a pie chart, where you can see information of how many was born in what place.
- The following contributed modules were advised:
- Examples
- CCK
- Views
- Chart
- Views_customfield
Err, forgot to mention that this is for Drupal 6, by request.
What?!
What indeed. No, I was joking.
I made the following design choises (will change as I improve my knowledge):
- Drop views|contrib, too difficult. Lol. Well yeah that, and because I can still managed without relying on the views' API. Could use the caching that it provided though.
- Add date|contrib. This is obvious. Wonder why they didn't list it there.
- Age calculation is done in SQL. Hm.. I wonder if that is wise.
- Birthplaces are taxonomy terms. Webmasters can add/remove/filter them easily.
- Previous item implies that I use content_taxonomy|contrib.
What the module does:
- Create a custom content-type, or node-type.
- Create CCK fields and attach them to our previous content-type.
- Create taxonomy vocabulary and terms if there wasn't one already.
- Clean up. Remove all those things it made: contents and content-type, CCK fields, taxonomy vocabs and terms.
- Implements theme_table.
- Uses Google Chart API.
Took me 3 days to complete something that was supposed to be finished in 1 work day. Not good.
Where?
The compressed file client_biodata.zip, is located on external site on google.com. Haha! I've just created a github account. Scratch that old link because I have a better one. My client_biodata repository on github is where all the excitement is going to happen, if there is any, easier project management and versioning system, no more zip and upload, w00t!
I haven't figured out how to upload file to tumblr.com blogspot.com. Probably not allowed.
Improvements to the code.
- Use url(), don't just generate relative url out of thin air.
- Using calculation on SQL is bad as it forced mysql to create temporary tables. There was a link on how to write effective SQL. This is going to be on my to-do list, as soon as I have time.
Damn.
Writing in html tags sure is hard.
Labels: custom module, drupal