I'm sure this will have been asked before, but I can't seem to find it...

I have CCK installed, and some custom nodes: along the lines of Author, Publisher, Book

I have a "Publisher" node with CCK fields for Name and Description.
I also have an "Author" node, with basic fields also.

Currently I also have a "Book" node that references a node for "Publisher" and "Author"

So far so good. But the problem starts here:

As a temporary measure, I have created a multi node reference in the "Author" node to "Book", but really I should be able to list Book nodes that have "Author =
"

I'm guessing that I can use the calculated field module for that, but my PHP is rusty, and I'm only starting to get into terms (I think!) with the Drupal ways.

My thinking is that I should be able to query the Book nodes for Publisher and Author (from calculated fields in the Publisher and Author nodes) for all kinds of things.

So:

1. Is this possible?
2. Is this how I should be approaching this problem, or is there a better/easier solution I've missed?
3. Are there any examples that I can check out, modules, sample code?

Thanks!

Comments

muso’s picture

Just to clarify my question (I don't think I can edit the question...): when I refer to "Book" node above - I don't mean the standard Drupal "book node", but a custom one created with the CCK module. It references the other CCK nodes my using the CCK node reference.

Even if someone can roughly point me in the right direction I will be so thankful!

JohnG-1’s picture

1. I think a quick solution would be to use the relativity module (http://drupal.org/project/relativity) to create bi-directional node relationships very easily. Although the parental analogy would suggest that 'Publisher' and 'Author' are parents to 'Book' nodes, the workflow (add child nodes to parent nodes) might be better the other way up - with Book as the parent to Publisher and Author ...

2. Another simple way to do this would be using taxonomy vocabs for Publisher and Author. The terms for each Publisher/Author can be generated automatically on creation of new Author/Publisher nodes using NAT module (http://drupal.org/project/nat) and selected from vocab lists on the Book edit page in the time-honoured way.

3. If all you need is a list of Book nodes where Author = x you could use Views (http://drupal.org/project/views) and build a quick view that takes the Author as a node reference argument and returns a list of Books. If you configure the view as a block it can easily be placed in 'content' so it looks like part of the Author node. Note this side of the Author-Book relationship is stored as a view (cached) as compared to the Book-Author relationship which is CKK data - this might affect which way round you want to push/pull the relationship, ie whether you the CCK noderef to reference Books from Author or Authors from Book.

muso’s picture

Thanks JohnG they all look like great options. :-) It'll take a little time going through them properly, and assessing pros and cons...

For info, I have tried your first option so far, and almost immediately needed to alter my database re this discussion:
http://drupal.org/node/76828

Relativity does make it really easy, and intuitive for users, but it has limited view options as far as I can tell, and I think I'm going to need a little more configurability than that.

The NAT module looks like an interesting option, but it still seems to be in beta for 5.1, and I'm a little nervous about trying it just yet. Can you tell me if this is more configurable?

Another option I've come across, which is a slight addition to your third suggestion is ViewFields (http://drupal.org/project/viewfield), which I think might be a better way of getting it to view in the main area, but I'm yet to check this out properly (this will take quite a lot more configuring, and experimenting to get to work) - I'll report my findings here again in case anyone else benefits from it.

JohnG-1’s picture

1. Relativity module is in the process of being 'upgraded' to work very nicely with views. At the moment there are a few patches queued for the next official 5.x release - the one I particularly recommend for what you're doing is Omar's Patch_4 (http://drupal.org/node/130870) which allows you to list children of type X for parent X as a view table or whatever - It does this in a very similar way to viewfields modul. Currently the patch is safe to install (I'm using it quite heavily), but will need one or two 'backwards compatibility' tweaks before it is committed to the official release. Thanks for the ref to the variables field length issue ... I hadn't come across that one.

2. NAT - I tried this briefly and found it stable and friendly. NAT is a very simple module and it's author - Moshe - also wrote the vastly complex organic groups module ... so I think NAT will be fairly safe :)

3. Viewfields, etc - check out the handbook page here for a couple more methods in that vein: http://drupal.org/node/48816

muso - I don't check these forum threads very often, so please feel free to PM me if I can help.

muso’s picture

I've been investigating the relativity module more, and see your name quite a bit!

This thread looks particularly interesting:
http://drupal.org/node/130870

Is it worth waiting to see how this progresses? (I'm not sure from the conversation, what the potential is).

Hopefully I'll get some time at the weekend to play around with the viewfield option...