2 Way street, Limit it to 1 level.

Comments

mikeytown2’s picture

2 way street as in actual reference and back reference
http://drupal.org/project/nodereferrer

This is actually quite hard to do from the looks. Given nid, get all cck node references (this node points to X (not very useful, X hasn't changed)) & all cck back references (X points to this node (very useful)). Flush all nodes, only going 1 level deep.

markus_petrux’s picture

Node Relationships can give you back references using dynamically built views.

This module implements methods to obtain node reference fields in a node based on its type, and how to automatically guess the name of the tables where node reference fields are stored, then you just build the query dynamically filtering for the reference column, and that can give you the sum of all nodes that point to a given node.

[EDIT] ie. you can ask CCK for node reference fields, then you can ask CCK which tables these fields use, then you can dynamically build the queries to obtain a list of all nodes that refer to a given node.

markus_petrux’s picture

Another module that can give you hints on how to ask CCK about fields and the tables they use:

http://drupal.org/project/cck_referential_integrity

mikeytown2’s picture

@markus_petrux
I guess there aren't any modules out there I can rely on (get nid's back); meaning I have to code this up, correct?

markus_petrux’s picture

Yes.

I was looking back to the code in CCK Referential Integrity, and I think it is small enough to figure out how this can be done. Look at the file cck_referential_integrity.inc as it contains a couple of functions used to ask CCK for fields, and functions to build this kind of queries dynamically. I hope it can help you deal with your task.

For example:

/**
 * Get information about reference fields of the given type.
 *
 * @param $field_type
 *   Field types supported are 'nodereference' and 'userreference'.
 */
function cck_referential_integrity_get_reference_fields($field_type) {
  $fields = array();
  foreach (content_fields() as $field_name => $field) {
    if ($field['type'] == $field_type) {
      $fields[$field_name] = cck_referential_integrity_get_field_info($field);
    }
  }
  return $fields;
}

In the same file there are functions that build queries dynamically.

mikeytown2’s picture

Priority: Normal » Critical

I need to do this.

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new4.77 KB

Yet another awesome feature, in support of longer cache times.

mikeytown2’s picture

StatusFileSize
new4.77 KB

fixed admin section

mikeytown2’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

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