Community Documentation

Media: Callback resource

Last updated January 27, 2009. Created by kleinmp on January 11, 2009.
Edited by aaron, arthurf. Log in to edit this page.

In your hook_media_register you declare callbacks for each of the functions that are needed by the registered type.

Specifically, the callback resource for resources expects data to be returned in an ordered format. This allows a module to define a tab inside of the the browser, a drawer, and the actual display pane. Your callback function should return code in the form:

<?php
 
return array(
   
t('My files') => array(
     
t('My Drawer') => media_resource_display_user_files_form($files, t('Your files')),    
    )
  );
?>

Here, an array is passed back. The first key in the array determines the tab title that this data is related to. If this tab does not exist, it is created. If it does exist the additional data is merged into the existing tab's data. The second key is the drawer or sub element title. The drawer title's data is a Drupal form array. Media provides default formatters that you can pass your resource listings to- here you see the media_resource_display_user_files_form() function which formats your data.

Media provides these basic display options:

  • media_resource_display_user_files_form() displays files in a list
  • media_resource_display_upload_form() displays an upload form

If you provide your own form, it is critical that you identify the resource that will be formatted with the following CSS classes: resource, select. These are the selectors that are used to find the selected resource and generated the formatter form for.

Page status

About this page

Drupal version
Drupal 6.x, Drupal 7.x

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here