Hello folks. Using this thread i would like to explain my idea for a custom module that will be used in an Intranet based enviroment. I have seen alot of development frameworks out there for creating such projects but after working with drupal for a couple of months i am certain i can develop modules with drupal itself.

I want to add, i have a decent knowledge of php and MySQL but a little understanding of the drupal core and how to use drupal hooks to develop what i need. Hope fully with a little guidence, i will be able to realise my goals.

So here goes:

I have played around with the CCK module and in most aspects it has been able to fulfil my needs but im looking for more. The main thing wrong with CCK is the way it creates the database structure. I want more control over this as outputting the data from the database is one of my interests.

I Have asked in #drupal about the complexity of my module and have been assured that it is a simple one to create so here goes.

I want to create a module with many node types that relate to each other in some form or another. With this structure of forms that relate to each other, i want to be able to query my tables and output a overview of this data in one table (think data warehouse). i Would also like to be able to view all the data via links in each submitted node to the other nodes related to it.

Let me give you a simple example:
----------------------------------
Form one - Add Person

Fields:

ID
First name (textfield)
Last Name (textfield)
Age (textfield)

Skills (tickboxes - these tickboxes link/relate to another table of data (professions))
-----------------------------------
Form two - Add Skill

Fields:

ID
Skill Name

Now, if i wanted to query all the people in my database and all thier skills i would do something like this:

SELECT * FROM people, skills WHERE people.skill_id = skills.skill_id

The example above is a pretty simple example of a relation database and forms and if i were to create this using my own PHP skills and write it from scratch i could probably do it very quickly but with drupal (and a lack of understanding) i am not able to do this simple function. I am really intersted in drupal module development and i have been told its a difficult learning curve but i want to learn. I have already completed the node_example tutorial as well as some others i found acroos the web but this simple function above i cannot do =(

How might i achieve this function? Can i get a simple example with the two forms?

Any and all feedback is appreciated

Harris

Comments

nevets’s picture

If you really want multiple nodes from a single module I would suggest you look at the case tracker module and casetracker_basic.module. Look for the function casetracker_basic_node_info() which defines two node types, 'Project' and 'Case'. The 'module' element tells you what the prefix for the related functions are, for example if you search for 'casetracker_basic_project', you will a function for building a form (the form hook) and determining access (the access hook). Because this module does not add any custom fields (it has no table for it's self) it does not have the insert, update, load and submit (optional) hooks that you would probably want to use.

But from you example I am not sure you really need/want to implement a node for each of these types. Skill for example can be done simply by using a taxonomy vocabulary called 'Skills' which is assigned/enabled for you content type 'people'. In this case you will also probably want to allow multiple terms. Add the skills needed to the vocabulary and now when you add/edit a 'people', there will be a drop down from which the skills can be selected. When you view the person the skills will be listed (you can use theming to change the look/layout), click a skill and it will show you all content (at this point people) with that skill. The bottom line is if you are trying to categorize data why not use what Drupal provides?