I am developing a custom module for one of my sites and I am asking myself a question which I often ask myself, which is:

How much should my custom module rely on the configuration of the site?

My specific example is this: I have a website that contains user groups. I would like each page of User Group content type to have a block on it where a user can join a user group by entering their email address and clicking submit. This would then be processed through a web service to another system (NetResults). One of the parameters to be sent to the web service is a field value from the User Group.

So obviously it would be real easy for me to create a custom block with a form, and to get that value to send to NetResults like this:

<?php
$param_for_netresults
= $user_group->field_list_id[LANGUAGE_NONE][0]['value'];
?>

But it feels wrong to me to rely on the configuration of a certain content type in my module. But the lure of it's simplicity is hard to resist.

I come accross this issue regularly (relying on a field to be present on a certain content type) and I have gotten around this before by adding a configuration page that asks which content type and field to use. But I wanted to see if other module developers had any thoughts on dealing with this issue and whether you are comfortable making certain assumptions about site configuration in your custom modules.

Thanks,
Brendan

Comments

I tend to make this

I tend to make this configurable, either per content type or system wide if only applies to one content type.

nobody click here