As per http://api.drupal.org/api/drupal/modules--field--field.api.php/function/... :

This hook MUST be defined in .install for it to be detected during installation and upgrade.

I need to trigger an update process of particular fields that are dependent on the adding or removing of references between nodes. I was interested in this module as a base model for this, I think it will be useful.

On a side note, do you know how much of this can be achieved with rules? I am not overly intimate with rules but feel that this should be possible if it is not. If it isn't what are your thoughts on a module supplying a the necessary events/conditions to trigger an action on the changing state of a reference field (be it user/node/taxonomy etc.)? One of the parameters being passed to the action being the added/removed references...

Comments

gilgabar’s picture

Thanks for noticing that. Despite the capital MUST it appears to have been working out ok living in the .module file, but it never hurts to follow the API. Just moved hook_field_schema() to .install, so it should show up in a dev release shortly. Please test and report back here once it is available. It should not break anything, but you never know.

Yes, I would think this would give you a good start if you want to respond to node reference changes. I would look at nodereference_count_references_update() and some of its child functions.

I'm not sure that this can be easily replicated with Rules. I won't say it's impossible as I have not tried it or even thought especially hard about it, but at first glance it doesn't seem likely. The basic things this module does are: create fields to store counts, query the database to calculate the counts, and respond to node reference changes to call the query as needed. The field part could probably be taken care of by a generic integer field. I don't think you could coax Rules into querying the correct tables and getting a count, but maybe something could be hacked together with Views. And if reference fields themselves don't have a Rules event associated with their changes, then you would still need to take care of responding to node reference changes.

I think that last piece would be a fine thing to be able to do with Rules (if it isn't currently possible). I'm not sure if it makes more sense to try to get the References module to add that support though. It seems like it would be simpler and/or more efficient, but like I said I haven't thought any of this through.

gilgabar’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.