I&#39;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&#39;t get views relationships to work correctly, and don&#39;t know if it&#39;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 &#39;views data&#39;. But hook_field_settings() was broken up into hook_field_schema() and hook_field_form_settings() and there doesn&#39;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 &#39;database columns&#39;:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      $columns[&#39;asin&#39;] = array(&#39;type&#39; =&gt; &#39;varchar&#39;, &#39;length&#39; =&gt; 32, &#39;not null&#39; =&gt; 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 &#39;views data&#39;:</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 &#39;many to one&#39; filter.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      $copy = $data[$table_alias][$field[&#39;field_name&#39;] .&#39;_asin&#39;];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      $copy[&#39;title&#39;] = t(&#39;@label (!name) - Allowed values&#39;, array(&#39;@label&#39; =&gt; $field[&#39;widget&#39;][&#39;label&#39;], &#39;!name&#39; =&gt; $field[&#39;field_name&#39;]));</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      $copy[&#39;filter&#39;][&#39;handler&#39;] = &#39;views_handler_filter_many_to_one&#39;;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      unset($copy[&#39;field&#39;], $copy[&#39;argument&#39;], $copy[&#39;sort&#39;]);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      $data[$table_alias][$field[&#39;field_name&#39;] .&#39;_value_many_to_one&#39;] = $copy;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      // Argument : swap the handler to the &#39;many to one&#39; operator.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      $data[$table_alias][$field[&#39;field_name&#39;] .&#39;_value&#39;][&#39;argument&#39;][&#39;handler&#39;] = &#39;views_handler_argument_many_to_one&#39;;</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[&#39;field_name&#39;] .&#39;_asin&#39;][&#39;relationship&#39;] = array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        &#39;base&#39; =&gt; &#39;amazon_item&#39;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        &#39;field&#39; =&gt; $db_info[&#39;columns&#39;][&#39;asin&#39;][&#39;column&#39;],</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        &#39;handler&#39; =&gt; &#39;views_handler_relationship&#39;,</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;"><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>