When creating a node-based view, I see how to develop a relationship with the root book node and fields to create a change history log. Unfortunately, only node revision log messages for each currently published node revision within the book is displayed.

When creating a node revision-based view, I see all node revision log messages; however, I cannot easily filter these down to nodes within a single book without the node-book relationship.

Am I missing something? Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stacysimpson’s picture

Anybody have suggestions for how to create a relationship between the node revisions table and book table?

merlinofchaos’s picture

In theory you would create the node_revision->node relationship which would then open up all the node information as well.

stacysimpson’s picture

Thanks for the input. The node_revision->node relationship is available. Here is the query that I need to generate:

SELECT node_revisions.vid AS vid,
   node_revisions.timestamp AS node_revisions_timestamp,
   node_revisions.title AS node_revisions_title,
   node_revisions.nid AS node_revisions_nid,
   book.bid AS node_revisions_bid,
   users_node_revisions.name AS users_node_revisions_name,
   node_revisions.log AS node_revisions_log
 FROM DP_node_revisions node_revisions 
 LEFT JOIN DP_users users_node_revisions ON node_revisions.uid = users_node_revisions.uid
 LEFT JOIN DP_node node ON node_revisions.nid = node.nid
 LEFT JOIN DP_book book ON node.nid = book.nid
 WHERE (UPPER(node_revisions.log) != UPPER('')) AND (node.type in ('book')) AND (book.bid = 515) AND (node_revisions.vid <= node.vid)
   ORDER BY node_revisions_timestamp DESC

Basically, I need the following:
1. Ability to join the node_revisions table with the node table and the book table.
2. Ability to pass in the root book node id as a parameter
3. Additional revision version filter for filtering out revision log messages for revisions that haven't been published yet.

From the views source code documentation, "The base relationship handler can only handle a single join. Some relationships are more complex and might require chains of joins; for those, you must utilize a custom relationship handler." It seems that I would need to create a custom relationship handler to join the node_revisions table with both the node table and book table.

Does anyone know if that is the correct direction? Any other thoughts or suggestion for how to approach the custom relationship handler? Many thanks!

merlinofchaos’s picture

Once you add the node_revision -> node relationship, node fields (Including book fields) should automatically become available for use with that relationship, so yes, that should be all you need to create this query.

stacysimpson’s picture

I don't see a method in 6.x 2.3 to create a node_revision -> node relationship. It seems to be one of what the documentation calls an implicit relationship.

stacysimpson’s picture

merlinofchaos (or others), appreciate the feedback, but wondering if you have any other thoughts. Again, the book-related information is not available when the 'node revision' base is chosen in Views. When choosing 'node' as the base, they work. Thanks again!

merlinofchaos’s picture

Category: support » feature

I think this is an unfortunate side effect of having an implicit relationship rather than explicit, which means you can't do this without a relationship which does not yet exist. :/

That makes this a feature request.

dawehner’s picture

Status: Active » Needs review
FileSize
456 bytes

So here is one

merlinofchaos’s picture

Status: Needs review » Needs work

'base field' should not be 'node'

The labelling on this field needs work. I couldn't find it at first. Relationships usually need separate title and help lines.

dawehner’s picture

Status: Needs work » Needs review
FileSize
510 bytes

Here is a from my perspective better help text

Node revision: Node
The revision ID of the node revision.
merlinofchaos’s picture

Version: 6.x-2.2 » 6.x-2.x-dev
Status: Needs review » Fixed

Changed wording a little more and applied to all branches.

Status: Fixed » Closed (fixed)

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