Discussion on the right approach to develop a roster module

jsabater - March 17, 2008 - 22:37

Hello everyone!

I have been using Drupal for more than a year now and, given that I have some free time now, I've decided to develop my first module. I am a Linux system administrator and web developer, so I am used to the technologies used by Drupal. Yet, I am still learning about the internals of Drupal.

I've read the module creation tutorial and followed and read many links I found there, all related to coding modules. Now I have a lot of information in my head and need to put order up there.

What I want to do is to create a roster module for the MMORPG Star Wars Galaxies. My basic idea is to create an entity called character and be able to associate one or many characters to an account. So the Drupal account would act as the persona, and it would have zero, one or many characters associated. One of these characters would be marked as main, although this is not strictly necessary, and this character entity would have attributes related to the game, like name, profession, rank, combat level, etc.

On a second version I would extend functionality to more aspects of the game, but so far I'd like to go with the associating characters to an account and listing them, with the ability to search and filter. Every account would be able to edit their characters, and those with the management role would be able to edit any character.

So, I would appreciate any feedback that experienced module developers could provide me. I've read about Drupal, as I said, but the learning curve is there and I am not yet done with it. So if you could point me at modules, libraries, helpers and any stuff from Drupal, and give me your two cents on the best approach for the module, that would be great.

Thanks in advance.

Should I define a new content type?

jsabater - March 18, 2008 - 19:38

So the first question that comes to my mind after reading some guides regarding nodes and content types is whether I should define a new type of content for the characters. So, a character would be associated with an account, as it's meant to be, and it would be searchable and I could set permissions so that people from management could edit any character.

Any thoughts?

content types and CCK

KingMoore - March 19, 2008 - 13:12

You might be able to do what you want to do just using CCK. What do you think?

I would start by defining your content types. As per your description above, the only content type I see is "Character." I would get CCK up and running and build a Character content type with all the fields you want. Then you can set the roles so anyone can create characters, but only edit their own.

Yes, that is a possibility

jsabater - March 19, 2008 - 15:36

Yes, that is a possibility that I had in mind too. If we consider a basic character, then I agree with your: it makes sense, it's enough. I define a new content type, set certain attributes to it and there we go: users can create new content of type "character" and they would have it associated to their accounts, which is what I want.

My problem is that I don't know whether it will suffice when I go for version 2 and so on, with extended stuff. That is why, so far, I am thinking of creating a module for it with a new content type (and also because I'd like to learn to develop modules for Drupal). But I still want to begin with something basic to get started, so I'll probably do as you suggest.

Also, I see the events module: they define a new content type, something that could be done without any programming (as far as I know about Drupal) due to Drupal's features, but then why do they create a module? Well, I guess it's because they want to define a block which you can put anywhere in your website with the list of incoming events, sorted by date or something. Also because they want to have a new entry in the left (main) menu so that people can click and quickly go to the list of events. But I don't know which of these do need a module to be programmed and which not (I bet that if they created a new module, it's because they needed to).

check here for a good

KingMoore - March 19, 2008 - 23:05

check here for a good example on building a module that creates a content type:
http://api.drupal.org/api/file/developer/examples/node_example.module/5

Should I use taxonomy?

jsabater - March 19, 2008 - 15:31

Second question that comes to my mind, after reading a lot about the taxonomy module, is whether I should use it. I mean, let's take one of the examples on the documentation about taxonomy: music genres. Users would add songs, and those songs would have a name, an author and a genre. Genres would be folk, rock, pop, etc. Therefore, I could use the taxonomy module to define those terms as a vocabulary. Whenever I needed to go beyond, as with origins, I could use the module to define a hierarchy (countries, regions, cities, etc).

Now I think of characters of the game and I say to myself: what is the difference between a profession or a rank and a genre in the example above? Then, should I define a vocabulary for the professions, another one for the ranks, and so on? I don't think so because they are attributes of the character, not categories (although we could also think of a profession as a category). And anyway I will be able to filter the list of characters you will access through the "roster" menu option by profession, rank, etc. (well, I expect you will, heh).

I am thrilled about the taxonomy module, but I don't yet understand when I should use it, and when it's not "necessary" or "better" (beyond the examples given in the documentation and in cases which are similar or match those).

Any hints?

 
 

Drupal is a registered trademark of Dries Buytaert.