1

I wanted to add a relationship to data in a View of an existing module, so I've hacked the code (the function modulename_views_data) and it works.

Now I want to create a new module to do this extension, leaving clean the original one. I guess I should use the function views_data_alter(&$data) but I don't understand how to bind it to the other module.

1

You would create a module. It only needs a simple modulename.info file and modulename.module file.

If you called your module 'mymodule', then in mymodule.module add the function:

mymodule_views_data_alter(&$data) { 
  \\custom code
} 

Clear the caches and you should be good to go.

The hook system allows modules to interact with other modules code. By naming your function MODULENAME_views_data_alter you are telling Drupal that you want to take advantage of the hook HOOK_views_data_alter.

  • It works! I had put this hook in a views.inc file to follow the original module pattern. – alez Feb 26 '15 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.