Add content type CCK field to join with custom table field in drupal view 2

Events happening in the community are now at Drupal community events on www.drupal.org.
mehtatejas's picture

Hi,
I have following table structure:
CREATE TABLE IF NOT EXISTS views_price (
nid int(11) NOT NULL,
price float NOT NULL,
UNIQUE KEY nid (nid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

In order to expose my price field in view, I wrote following code

function mymodule_views_api() {
return array(
'api' => 2,
'path' =>
drupal_get_path('module', 'mymodule'),
);
}

function mymodule_views_data() {
$data['views_price'] = array(
'table' => array(
'group' => 'My Custom Data',
'title' => 'views_price',
'join' => array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
),
),
'price' => array(
'title' => t('Price'),
'help' => t('A product price generated
by the mymodule module.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
),
);

return $data;

}

Further, I had created cck field in my blog content type as blog_price.

I want query similar to following in drupal view 2:
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
LEFT JOIN content_field_blog_price content_field_blog_price ON node.nid = content_field_blog_price.nid
LEFT JOIN views_price views_price ON views_price.nid = content_field_blog_price.nid
AND content_field_blog_price.field_blog_price_value = views_price.price
WHERE (node.type in ('blog'))

Please help me to create such views.

Thank You
Tejas

Comments

*_*

beautifulmind's picture

Try custom php filter and php fields.

India

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week