How do I create a relationship between an "external" content (with NID field) and standard nodes ?
Is there a way to create a view that include both ?
All I saw is a way to create relationship between two external tables.
I don't want to migrate content - I want to keep using the external table, which already "sync" with standard nodes, only without Views...

Hope I was clear enough with my question.
Regards,
Shushu

Comments

mikeryan’s picture

Component: Miscellaneous » Code
Category: feature » bug

It should be possible to add the node table to Table Wizard, then add a relationship to that, but this seems to be broken at the moment. I will investigate...

frankcarey’s picture

just a hint: i think i noticed this from last dev version where "existing" views tables didn't show up.

mikeryan’s picture

OK, it's a little better, but not perfect - manual relationships from another table to node seem to work fine, automatic relationships are a bit flaky (only the nid shows up by default, and other node fields show Array() in the views UI where they should show Node).

frankcarey’s picture

I just came across this issue as well. The problem is that tw is naming the internal tables inconsistently (at least with map tables).


 $data['migrate_map_36'] = array(
    'sourceid' => array(
      'title' => t('sourceid'),
      'help' => t('migrate_map_36.sourceid'),
      'field' => array(
        'handler' => 'views_handler_field',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_numeric',
        'allow empty' => TRUE,
      ),
      'argument' => array(
        'handler' => 'views_handler_argument_numeric',
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    ),
    'destid' => array(
      'title' => t('destid'),
      'help' => t('migrate_map_36.destid'),
      'field' => array(
        'handler' => 'views_handler_field',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_numeric',
        'allow empty' => TRUE,
      ),
      'argument' => array(
        'handler' => 'views_handler_argument_numeric',
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    ),
    'needs_update' => array(
      'title' => t('needs_update'),
      'help' => t('migrate_map_36.needs_update'),
      'field' => array(
        'handler' => 'views_handler_field',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_numeric',
        'allow empty' => TRUE,
      ),
      'argument' => array(
        'handler' => 'views_handler_argument_numeric',
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    ),
    'table' => array(
      'group' => t('migrate_map_36'),
      'base' => array(
        'field' => 'sourceid',
        'title' => t('Database table migrate_map_36'),
        'help' => t('Mappings from source key to destination key'),
        'weight' => 10,
        'database' => NULL,
      ),
    ),
  );
  $data['external_db.migrate_map_36'] = array(
    'table' => array(
      'group' => 'default.migrate_map_36',
      'join' => array(
        'matadortravel_live2_copy.users' => array(
          'left_field' => 'uid',
          'field' => 'sourceid',
        ),
      ),
    ),
  );
  return $data;

This is what I get when I export the definitions from TW. So, I think we need to either made sure that TW uses db.table all the time, or consistently doesn't use it for default tables. I vote for consistently just using the table name for default tables.

frankcarey’s picture

tw_qualified_tablename still needs some love, but this will at least get it to only use the database for external tables only. I changed:

 if (function_exists('views_clean_alias')) {
//TO
 if (function_exists('views_clean_alias') && $dbconnection != 'default') {

Here is how I have it in my dev version.

function tw_qualified_tablename($dbconnection, $tablename) {
  global $db_type;
  // MySQL is the one support db known to handle this
  if ($db_type == 'mysqli' || $db_type == 'mysql') {
    // And we also need the Views patch ...
    // to pull this off
    views_include('query');
    // make sure that the views patch is working and that we are dealing with a external database.
    if (function_exists('views_clean_alias') && $dbconnection != 'default') {
      return tw_get_dbname($dbconnection) . '.' . $tablename;
    }
    else {
      return $tablename;
    }
  }
  else {
    return $tablename;
  }
}
mikeryan’s picture

Status: Active » Fixed

Fixed - group field was getting messed up.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.