views:

157

answers:

1

I'm looking for a way to construct a view in drupal6 by letting it grab the 'added date' from a nodereference cck field which has multiple values.

What I need is a list of titles of referenced nodes, sorted (desc) by the date they were added to the reference-list.

I've tried setting up a 'node' view, letting it grab a node ID from the url and letting it display node titles that are linked by a relationship to the cck field. When sorting it by 'revision date' or 'revision vid' I obviously got the "normal" list, since all entries were present in the latest revision.

Any ideas on how to tackle this?

A: 

I'm not sure this is actually possible in SQL the way I'm understanding it. If I'm understanding correctly you want the revision date of the attached nodes but these nodes are being joined on through a relationship which will make their revision_date look something like attached_node.revision_date and attached_node_2.revision_date. So sorting by revision date would be ambiguous but you can't sort on the same column from two different tables.

So you may have to redefine the goal, or if you can figure out the SQL (maybe I'm just filled with turkey and slow today) but views can't handle it you can use hook_views_query_alter in your module and adjust $query->where iirc. You can also hook_views_pre_execute though this is distinctly uglier and requires that you be able to parse the SQL. It's nice if you're just going to replace the SQL entirely though on some view and only use the views ui for its wonderful argument and outputting options.

Chuck Vose
"If I'm understanding correctly you want the revision date of the attached nodes"I'm looking for the date the nodereferenced node was added to the viewed node.
Haiko
Ah, I understand. Unfortunately with stock CCK I don't believe this is possible. You could certainly do a nodeapi hook that facilitates this but I don't know of any other way. There may already be a module to do this but I've not run across it yet. Would you like more description about how to do the nodeapi hook or are you familiar with creating modules?Also, I'm curious about why you've chosen this path. What are you getting from knowing when a node is attached?
Chuck Vose
well, it's like this. I have pages that hold information on certain events. Artists (also nodes) that are most likely to be joining the event, are linked by a nodereference CCK field to this node. The goal is for visitors to see which artists have been most recently added to the list. By the way, I have very little experience with building custom modules / nodeapi hooks. I would really appreciate it if you could send me in the right direction.Cheers!
Haiko
Cool, so here's the deal with nodeapi. Basically, it can hook into anywhere in drupal and change things as they happen. A really, really common thing to do would be to hook into node_save and when someone gets attached via nodereference you could save the datetime to a new table. The place to go for this is Pro Drupal Development. I'm usually not one for buying books but for Drupal this is actually completely required reading. We have 4 in the office and every one is ragged with use.
Chuck Vose

related questions