Hi
I have a very useful module that uses views to create a spreadsheet based upon two separate tables "left joined" and it works great. I wanted to add some new functionality by using CCK to gather some dates and that is where the fun begins. My "Usage Profile" content type now includes content_type_usage_profile and the content_field_date as well usage_profile and usage_profile_data.

If I choose to create a type "Node" then I see the CCK fields I want however I lose access to my leff-joined table however if I choose to create a type "Usage Profile" I find all my leff-joined data but lose access to the CCK fields.

I don't really mind which way I fix this, though the least amount of work for me I suspect would be to expose CCK to my Usage Profile type, if that is not possible I'd be happy with exposing my left-joined table to the Node type. However, I don't know how to tackle either of these and was hoping somebody here can point me in the right direction.

Comments

merlinofchaos’s picture

Status: Active » Fixed

Your best bet will be to create a relationship from your Usage Profile to node -- by adding that relationship to your view, everything associated with nodes would become available. This is a lot easier than trying to specifically relate CCK data to your base table by modifying CCK's tables.

A good example of very simple relationships is the comment user relationship in comment.views.inc

Dave Kinchlea’s picture

Status: Fixed » Closed (fixed)

Perfect, thanks! Works like a charm, easy as pie to setup and it gave me exactly what I wanted.

For anybody interested, I already had the relationship entrenched in code, I just had to tell views about it. I added the following to usage_profile.views.inc:usage_profile_views_data()

  $data['usage_profile']['nid'] = array(
     'group' => t('Usage Profile'),
     'title' => t('NID'),
     // Table relationship
     'relationship' => array(
      'label' => t('Node'),
      'base' => 'node',
      'base field' => 'nid',
      // This allows us to not show this relationship if the base is already
      // user so users won't create circular relationships.
      'skip base' => array('node')
    ),
  );