[development] tying user and content_profile together in a view or module

Andrew Berry andrewberry at sentex.net
Thu Oct 29 05:12:35 UTC 2009


On 2009-10-29, at 12:57 AM, Larry Garfield wrote:

> Sadly I don't know of a full-on relationship handler from nodes to  
> their
> users, which would let you get from an arbitrary node to its owner  
> to that
> owner's profile nodes.  But I have been wrong about such things  
> before. :-)

You can do n*way relationships, but I'm sure the performance sucks  
with many relationships (as they are usually cross-table joins). You  
can "chain" relationships in the UI just be selecting a pre-existing  
relationship.

In your case, I don't think you even need 2 relationships. Build a  
node view, create a relationship of "Node: content profile" and it  
will join on the content profile of the author of each node. I got the  
following query showing me a view of all book pages and the title of  
their author's content node:

SELECT node.nid AS nid,
    node_users.title AS node_users_title,
    node_users.nid AS node_users_nid,
    node_users.language AS node_users_language,
    node.title AS node_title,
    node.language AS node_language
  FROM node node
  INNER JOIN users users ON node.uid = users.uid
  LEFT JOIN node node_users ON users.uid = node_users.uid AND  
node_users.type = 'profile'
  WHERE node.type in ('book')


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2672 bytes
Desc: not available
Url : http://lists.drupal.org/pipermail/development/attachments/20091029/c64524a6/attachment-0001.bin 


More information about the development mailing list