5

I have some requirements that leads me to extend the functionality of a views plugin style implemented by a contrib. module by adding some fields and validations in it's configuration form.

I started to implement a custom module to alter this by extending the contrib_views_plugin_style Class implemented by the contrib. module using the views API. I added the fields with no problem but I'm worried about the render method because I don't want to have a copy of the contrib. plus my custom code and I still not sure if this is the best way to do this.

I plan to post this to d.o by posting a patch or maybe another contrib. module but it would be nice if I could keep just the new code and didn't have to have any duplicated code.

Here is the contrib module code:

http://drupalcode.org/project/leaflet.git/blob/refs/heads/7.x-1.x:/leaflet_views/leaflet_views_plugin_style.inc

There is another way to achieve this goal?

PS. I prefer to start without hacking the contrib module but if there is no way to do this it's OK.

1 Answer 1

1

First you need to have a my_module.views.inc, which can have basically the same contents as http://drupalcode.org/project/leaflet.git/blob/refs/heads/7.x-1.x:/leaflet_views/leaflet_views.views.inc, but with changed names.

You can leave the handler the same, in which case you need to leave the path the same too. Otherwise you can create your own hadler in my_module_views_plugin_style.inc along the lines of

class my_module_views_plugin_style extends leaflet_views_plugin_style {
   // ...
}

You then only need to define any methods that you want to modify:

function option_definition() {
  $options = parent::option_definition();
  // your changes here
  return $options;
}

You also need a theme file. If you are modifying the display at all, you probably need to just copy the theme file over from the dependency, and change the 'theme' line in my_module.views.inc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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