did you run coder on it?

hazze - September 29, 2008 - 07:37
Project:Recipe
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:critical
Assigned:Unassigned
Status:active
Description

How to patch the recipe module to be accessed in views.

For example list recipes that includes specific ingredients and so on.

#1

hazze - September 30, 2008 - 07:32

I have figured out that i need to implement hook_views_data() and place it in MODULENAME.views.inc (recipe.views.inc).

After a lot of reading and testing i'm not getting it right.

I use the following code:

<?php
/**
* Implementation of hook_views_data()
*/
function recipe_views_data() {
  // Define the base group of this table. Fields that don't
  // have a group defined will go into this field by default.
  $data['recipe']['table']['group']  = t('Recipe');
  $data['recipe']['table']['base'] = array(
   'field' => 'nid',
    'title' => t('Recipe'),
    'help' => t("Recipe content."),
    'weight' => -10,
  );

$data['recipe']['table']['join']['node'] = array(
  'left_field' => 'nid',
  'field' => 'nid',
);

$data['recipe_ingredient']['table']['join']['recipe'] = array(
  'left_table' => 'recipe_node_ingredient',
  'left_field' => 'recipe_ingredient',
  'field' => 'id',
);

$data['recipe_node_ingredient']['table']['join']['recipe'] = array(
  'left_field' => 'nid',
  'field' => 'nid',
);

$data['recipe_ingredient']['id'] = array(
  'title' => t('Nid'),
  'help' => t('The ID of the ingredient.'), // The help that appears on the UI,
  // Information for displaying the nid
  'field' => array(
    'handler' => 'views_handler_field_node',
    'click sortable' => TRUE,
  ),
  // Information for accepting a nid as an argument
  'argument' => array(
    'handler' => 'views_handler_argument_node_nid',
    'name field' => 'name', // the field to display in the summary.
    'numeric' => TRUE,
    'validate type' => 'nid',
  ),
  // Information for accepting a nid as a filter
  'filter' => array(
    'handler' => 'views_handler_filter_numeric',
  ),
  // Information for sorting on a nid.
  'sort' => array(
    'handler' => 'views_handler_sort',
  ),
);

  return $data;
}

#2

inocram - October 29, 2008 - 22:55

Hello, were having the same problem here.. I hope someone will help.

#3

bstoppel - December 18, 2008 - 17:38

I am having the same problem. Did you resolve this?

#4

sfmerv - December 21, 2008 - 15:35
Title:Access recipe ingredients in Views» did you run coder on it?

did you run coder on it? I think you don't need the t() anymore, but that should't break it

 
 

Drupal is a registered trademark of Dries Buytaert.