Developing custom modules to add Provider plugins to Embedded Media Field
Last modified: February 1, 2009 - 02:54
This page documents the various hooks of the Drupal core, as well as CCK and Embedded Media Field, in order to implement a separate custom module that uses them to create a custom node to embed a media from third-party sites.
I could not find any other API documentations for Embedded Media Field and these are the basic notes I took as I reviews the code of those modules to tackle the above stated problem. Please let me know/correct this page if it contains wrong information. You may add more details.
- Create folder mymodule
- Create mymodule.info in mymodule folder
; $Id$
name = MyModule
description = A short description for MyModule
core = 6.x
dependencies[] = content
dependencies[] = emfield
Note that the dependencies for content (CCK) and emfield (Embedded Media Field) modules. This ensures that your module which provides plugin for Embedded Media Field, does have all the required functions available. The users of MyModule will have to install and activate these modules. - Create mymodule.module in mymodule folder
Implement the following hooks:- hook_menu
- hook_theme
- hook_field_info
- hook_field_settings
- hook_field
- hook_content_is_empty
- hook_field_formatter_info
- hook_field_formatter
- hook_widget_info
- hook_widget_settings
- hook_emfield_info
- hook_emfield_settings
- Create mymodule.theme.inc in mymodule folder.
This should implement all the theme functions specified by hook_theme - remember to indicate this file in the return array.
Alternatively, you do not create a new file and implement it in the .module file itself if there are less number of theme functions. - Create folder mymodule/providers
- Create multiple PROVIDER.inc files for each provider in mymodule/providers
Implement the following hooks in each of the .inc files:- mymodule_PROVIDER_info
- mymodule_PROVIDER_data
- mymodule_PROVIDER_extract
- mymodule_PROVIDER_embedded_link
- mymodule_PROVIDER_image_url
- mymodule_PROVIDER_image_title
PROVIDER should be the name for each of the providers you want to make available with mymodule.
You may also want to provide automated CCK content type creators in the .install files.
