I didn't get a response to this one, but in case others run into this, I wanted to mention the answer.<br><br>Synopsis: Extended views support for relationships and the like has moved into Views, whereas it used to be in CCK.<br>
<br>I got outstanding support from yched (fields) and dereine (views) on this. The issue was <a href="http://drupal.org/node/761372">http://drupal.org/node/761372</a><br><br>I did update the <a href="http://drupal.org/node/728792">Updating CCK Fields Modules from D6 to D7</a> page with this info.<br>
<br>Thanks,<br>-Randy<br><br><div class="gmail_quote">On Fri, Apr 2, 2010 at 11:19 PM, Randy Fay <span dir="ltr"><<a href="mailto:randy@randyfay.com">randy@randyfay.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm porting Amazon module to D7. (All the code is in the dev version at <a href="http://drupal.org/project/amazon" target="_blank">http://drupal.org/project/amazon</a>).<br><br>I can't get views relationships to work correctly, and don't know if it's a views issue or fields issue (probably?)<br>
<br>1. The asin module in the Amazon project provides an ASIN field. This works fine already. You can add asin elements to a node, it displays right, themes right, everything.<br><br>2. Views is happy to do a node-type view and offers an ASIN as a field, and displays it, themed correctly.<br>
<br>3. Amazon provides a full amazon_item data type to views, quite a rich set of data about any amazon item, with prices, pictures, author, and all manner of detail data all available as views fields. Views is very happy to present all this data in an amazon_item-type view.<br>
<br>4. BUT: The relationship between a node with an ASIN field and the Amazon item data is not there. No relationship is offered. So the most popular feature of D6 Views with Amazon is out of reach: The ability to display an incredible views list of nodes with lots of rich data about the Amazon items in its fields.<br>
<br>In D6, asin_field_settings() (hook_field_settings()) had the mapping, I think, provided in a $op called 'views data'. But hook_field_settings() was broken up into hook_field_schema() and hook_field_form_settings() and there doesn't seem to be anything like this any more.<br>
<br>Thanks for any help or ideas!<br><br>-Randy<br><br>Below is what the D6 asin_field_settings() had:<br><br><span style="font-family: courier new,monospace;">function asin_field_settings($op, $field) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> switch ($op) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> case 'database columns':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $columns['asin'] = array('type' => 'varchar', 'length' => 32, 'not null' => FALSE);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return $columns;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> case 'views data':</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $data = content_views_field_views_data($field);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $db_info = content_database_info($field);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $table_alias = content_views_tablename($field);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // Filter: Add a 'many to one' filter.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $copy = $data[$table_alias][$field['field_name'] .'_asin'];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $copy['title'] = t('@label (!name) - Allowed values', array('@label' => $field['widget']['label'], '!name' => $field['field_name']));</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $copy['filter']['handler'] = 'views_handler_filter_many_to_one';</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> unset($copy['field'], $copy['argument'], $copy['sort']);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // Argument : swap the handler to the 'many to one' operator.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'views_handler_argument_many_to_one';</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // Add a relationship for related node.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $data[$table_alias][$field['field_name'] .'_asin']['relationship'] = array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'base' => 'amazon_item',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'field' => $db_info['columns']['asin']['column'],</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'handler' => 'views_handler_relationship',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return $data;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><font color="#888888"><br clear="all"><br>-- <br>Randy Fay<br>Drupal Development, troubleshooting, and debugging<br>
<a href="mailto:randy@randyfay.com" target="_blank">randy@randyfay.com</a><br>
+1 970.462.7450<br><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Randy Fay<br>Drupal Development, troubleshooting, and debugging<br><a href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>+1 970.462.7450<br><br>