Wouldn't it be nice to make a table view including also other fields from the referenced node, not only the title?
I think that's what people are requesting here: http://drupal.org/node/91792

This is what views_fusion enables one to do, but the node relation module has to support it. I've just wrote this support for cck nodereference fields.
I've done a bidirectional support so this scenario is also possible: Create a view of the referenced nodes and add other fields of the node containing the references.

attached is a patch for the nodereference module, which just adds the views_fusion integration. It applies to 5.x as well.

Comments

fago’s picture

StatusFileSize
new7.83 KB

attached is a screenshot of a possible use case:

2 node types, cds and artists. cds contain a nodereference field referencing to artists.
the screenshot shows the view created with the help of views_fusion and the nodereference support. It lists fields from the cd content-type (title, created) and fields from the artists content type (title, country).

karens’s picture

I looked at the code but didn't try it. I like the idea of adding in a join to the node table for the reverse node and I think I can see how that could be useful to other modules in various ways. My concern is adding in a specific views_fusion function to the module. If the table join is made available, isn't there some way views_fusion can take it from there without adding any code to the nodereference module? We keep getting requests to add in code that is specific to other modules and I'm concerned about that for lots of reasons -- code bloat, harder to maintain, problems in the future when everyone forgets why it got done that way in the first place, etc. etc.

Also we now have a new method for custom handling of Views tables and should probably use it here, partly so we have a core module using it that can be used as a reference by module developers.

yched’s picture

+1 on Karen's concerns about contrib module specific code. I wouldn't have put it better.
That's also what bugs me in http://drupal.org/node/108226 (even if one-line patch)
Not meaning that i'm opposed to any of this, of course, but it would be nice if we could find a clean way.

+1 on the use of the new views tables handling in cck, for example sake.

fago’s picture

StatusFileSize
new2.13 KB

views_fusion could do it on its own, but from where should it know which fields does contain a nid?

hook_views_fusion doesn't nothing more than just saying, use this field to join to another node table. If modules create a node relation, they have to expose their nid columns to views_fusion or it doesn't know from it.
The only other way which comes to my mind is adding it as another property to the views table definitions directly.

The additional table definition for views, which is used by views_fusion could be theoretically incorporated into views_fusion. However I decided against doing so, as it might bloat the views table definitions unnecessarily if views_fusion creates table definitions on its own, as most times there is already an usable table definition like it is for the not reversed nodereference node relation.

I understand your points, but all what I can offer is helping support this part of code in the future, what I would have done in any case.

I have seen the new possibility of providing custom views table definitions, however I've not done so, because I don't wanted to loose the default definitions.
However attached is a patch which just loads the default definitions before adding the custom one. Again the patch applies to 5.x too.

stoltoguzzi’s picture

If I have Customer and products,

- I will add a node reference to products in customer
- create a view for customer containing the node_reference field, what the argument should be, node ID?
- create a view for producst add some field of this products, what the argument should be?
- in fusion parent ist customer, chield is product.

could not get it to work.

stoltoguzzi’s picture

sorry, patch was not implemented correctly on 5.x.
Now it looks ok!

fago’s picture

I've marked http://drupal.org/node/125522 as a duplicate of this.

karens’s picture

@fago, instead of creating a special view_fusion function can you re-work this into a reverse table info hook that views fusion can use to get the info it needs. That hook can then also be used by other modules that need this info which makes the code less specific to Views Fusion and opens up other ways to take advantage of that info. I think that would be a better way to work this in.

fago’s picture

ok, but could you explain the reverse table info hook a bit further? I can't really imagine what you are thinking of.

fago’s picture

Any updates? Please explain the solution you 'd prefer, I'd really like to get this in

dhsiao’s picture

Hello,

I am trying to use nodereference for view fusion but could not get it to work.

I patched my nodereference.module with the patch that you supplied above ("cck_nodereference_views_fusion_47_2.patch").

I have a content type called "tenant complaint," which includes a node reference field to content type "tenant." In the content type "tenant" I have another node reference to "building."

How do I set up the views fusion, and what relationship do I need to set up to make a table in views that show both "tenant" field in "tenant complaint" and "building" in "tenant" content type?

Thank you for your help

fago’s picture

although you are using the patch of this issue, this is a general views fusion support request. So please create a views fusion issue for it and I'll try to help you. All others which need help on using this patch, please do also so - let's keep this issue clean.

rickvug’s picture

Subscribing.

discursives’s picture

subscribing. really would like to access additional fields this way from referenced node.

noah@groups.drupal.org’s picture

Subscribing. This functionality could be extremely useful for me.

nipsy’s picture

Status: Needs review » Needs work

my god, this can make things so much easier. PLease reply to guzzi, that is an example that makes sense to a lot of people and will show 'apartment' how to do it also.

CentEur’s picture

Version: 4.7.x-1.x-dev » 5.x-1.4
Category: feature » bug
StatusFileSize
new19.23 KB

I can't make reverse direction work on node reference in views fusion widget. I get a fusion with empty column 'using' in views fusion widget.

Here's what I did:
1. Patched nodereference.module (cck 5.x-1.4, Drupal 5.0) with cck_nodereference_views_fusion_47.patch
2. Patched nodereference.module with cck_nodereference_views_fusion_47_2.patch (onto previously patched version)
3. Run update.php
4. Created 'referenced' content type (title field only) and 'referencer' content type (title field and nodereference field to 'referenced'). Added some content of both types. Added table views for both types (Node: Title field only).
5. In views fusion widget I could fuse successfully 'referencer' (primary) with 'referenced' view using "straight" Node Reference. But when I tried to fuse 'referenced' as primary with 'referencer' using Node Reference - reverse direction something goes wrong and views fusion widget reports new fusion with 'using' column empty.

I attached error message (when trying to view referenced table view) concatenated with my nodereference.module contents.

fago’s picture

Version: 5.x-1.4 » 5.x-1.x-dev
Category: bug » feature

stop hijacking this issue with support requests!

CentEur’s picture

My apologies. There's similar request above (#5) which made me think here's the right place for mine. My fault. Somebody please remove my comments (if it's possible).

fago’s picture

StatusFileSize
new2.19 KB

here is a rerollled (working) patch for the latest CCK

moshe weitzman’s picture

Status: Needs work » Needs review

interesting. i hope to test the new patch.

moshe weitzman’s picture

@fago - i think what Karen is saying is to keep the reverse table in this patch, but remove hook_node_fusion() and keep that out of CCK. you might also remove the comment "which are needed by views_fusion ".

fago’s picture

hm, but it's true, this tablejoin is only needed by views fusion, as there aren't any available fields or filters for it.. - so what's wrong with the comment?

removing hook_views_fusion, would obviously remove the views_fusion support.
It's needed, so that views_fusion is aware of existing node relation tables.

I'd be fine with moving it out of CCK, if you tell me how? :)
There is currently no way to identify node relation tables else. Another way would be to rely on a node relation API..

aren cambre’s picture

Subscribing. I think this is a great, commonsense functionality improvement. Views Fusion/Nodefamily isn't very useful to me without this. I'm trying to create several parent-child relationships based on node references.

aren cambre’s picture

BTW, just want to confirm that fago's June 7 patch appears to work for CCK 1.6. The line numbers may not exactly match up, though.

aren cambre’s picture

I think I found a bug, but I am not sure whether it's related to this patch.

I have two nodes: Office (e.g., President, VP, etc.) and Person. Office contains a nodereference to a person. E.g., the Office node representing the President will have a nodereference pointing to the person who's in that office.

I have one view that just shows Office nodes, and it just shows the office name. I have another view that shows Person nodes, and it shows the node title and two other fields about the person.

I have created a relationship between these nodes using Node Families, and I have used admin/build/views/fusion to define that the office view has Person as the fused view using the nodeference pointing to a person.

OK, now for the problem.

The fused view shows the Office node title, the Person node title and those other two fields about the person. The problem is that the person node title points back to the Office node and not the Person node. Logically, the Person node's title should point to the Person node, not the Office node, since it is only the fused/dependent view that contains the Person node's title.

ellanylea’s picture

great discussion, subscribing.

goose2000’s picture

Hi,

What about support for just some CCK integer field, and store the parent nid in there for child types. I don't get why ' node reference ' is needed specifically for this views fusion support? It (NR) worked by searching a node 'Title' last I looked. How is this a good unique identifier?

zostay’s picture

subscribe

liquidcms’s picture

hey guys... was using the patch and was working great.. but had other errors when using nodereference - upgraded to latest cck (1.6)/views and fixed those issues.. but then lost the patched nodereference.module

i manually applied the patch to 1.6 and it doesnt seem to work.

no errors just doenst merge the views.. i just get primary view results even though joined to secondary and secondary does have results.

both pri/sec views have arg passed but i dont think that means they need to have same URL (myPri/$arg) to make the arg still pass to sec? correct?

if i set them to same arg then i only get results of Sec at the url (i.e no union just picking up the last view.

either way.. it all worked before with cck 1.5

liquidcms’s picture

ok, my bad.. working too many late nights...

i use both views union and fusion with noderef...

the patch does work for 1.6 (well the 1.5 patch failed but doing it manually worked)

it is views union that broke with update of cck/views

sorry.. and i'll see about providing 1.6 version of fago's patch.. btw .. would really be nice if we got this committed.

aren cambre’s picture

What is holding this up from going into a released module?

aren cambre’s picture

Hmm, actually, maybe this is not working after all? I have a fused view, but I can only see data from fields contained in the primary node type in the view, not the "fused" node type. Let me explain:

ViewUnits: List of Unit nodes, each which has a Place nodereference. (Unit = Boy Scout troop/pack/whatever. Place = where the Boy Scout unit meets.)
ViewPlaces: List of all Place nodes.

Each Place may have multiple corresponding units. E.g., one church could have two units: a Cub Scout Pack and a Boy Scout Unit. So two distinct units may have the same place as a nodereference. Unit is the parent, Place is the child.

Views Fusion fuses ViewUnits to ViewPlaces like this:
primary view = ViewUnits
fused view = ViewPlaces
using = Node Reference: Location (field_place)

In ViewPlaces, I can add Nodereference fields that refer to Unit's CCK fields. I added Unit's Type and Number fields though this.

In the fused ViewPlaces view, which is set up as a table view, I see Type and Number columns but no data in the columns.

Another fault is I see no way of adding the Unit's title field to ViewPlaces. This is important because the Unit's title field uses Automatic Nodetitles to set the title to [Type] [Number]. E.g., if Type=Troop and Number=1032, then the resulting Title field is Troop 1032. Right now, I have to list two separate fields (Type and Number) instead of showing one field (Unit's Title).

scedwar’s picture

critical feature. subscribing.

coworksbe’s picture

subscribing

liquidcms’s picture

I have seen an issue which may be the same as #33.

When ever i update a primary view the is_cacheable bit gets set in db. When this happens, i lose the images that get fused from another node type. I think what happens then is the primary view gets cached without the fused view and then, since cached, we never get to fuse the secondary view.

Hard to imagine that anyone has this module working if this is always happening, so there must be something else in my combination of settings that allows this to happen. If i manually go into db though and flip the bit to not cacheable - but fused content comes back (until i resubmit the pri view again).

My quick work around for this has been so set a dummy argument (with display all values) for the view. With ARGs set, the view won't be set to be cached.

real fix however would be that if fused; view shouldnt be cached - or, i guess better yet - if fused, cached version should be the fused view.

Peter Lindstrom
LiquidCMS - Content Management Solution Experts

aren cambre’s picture

ptalindstrom: just to make sure I understand, are you talking about the Drupal-wide caching feature or are you talking about a caching feature specific to views?

liquidcms’s picture

I think as of Dr5 these are pretty much one in the same. The cache_views table holds a pre-fused query that it uses to create the page. If the views_view - is_Cacheable is 0 then this doens tget set and my fused view works as their is no entry in this table.

mkmckinn’s picture

Primarily for subscribing,
But... Might a new Handler in Views with an option for CCK field on which to join (Join Field) and a selection of node type (Master Node Type) on which to select the information be possible?
Imagine two tables: a) a main node table, and b) a CCK target field append table. The former a) is the beginning of the views module. The latter b) is a join between two subqueries: 1) the CCK target field table (a required table for the join field to be on two or more content types) grouped on the target node, and a join on a new instance of the node table joined to the new target node table by new target node type - using the CCK joining field.
Would this not allow all the elements From the Master Node Type to be exposed in the final view?

Sadly, I'm not much of a PHP coder, but I'd be happy to test. ;)

andy inman’s picture

Does anyone have a working patch for cck 1.6-1 (current) please? I don't really want to try manually patching as I'm new to both Drupal and CCK and don't want to break anything.

interfaced’s picture

I'm not sure if this is the right place, but here is an example of what I'd like to do. Note this is an easy example, not my actual need.

2 node types: Countries & Buildings

Each building has a node reference to a country. A country does not have any additional fields.

I need a view which displays the following without affecting the country node:

Country1
-Building2
-Building3
-Building4

Country2
-Building1
-Building6
-Building5

Does this patch make it possible? If so, how do I apply the patch? Thank you very much!

ldway’s picture

subscribing

bestknight’s picture

One of those *it works* moments for me...

changed column "uses" of views_fusion table to length 128 from 32, in accordance with http://drupal.org/node/145397 comment #5 and

applied #20 patch (manually) to CCK 5.x-1.6-1, using Views 5.x-1.6 and Views Fusion 5.x-1.2 and it does work

ChrisBryant’s picture

subscribing

ecoluke’s picture

Title: views fusion support for nodereference » views fusion support for nodereference - errors and failure
Category: feature » support

Hey,

I can get Views Fusion to work fine but the patch to make it work with CCK isn't the same!

Basically after I installed and patched everything I get the following sequence of events:

http://www.brokebust.com/_work/views_fusion_cck_001.jpg

Here I am following the tutorial and fusing the artists view into the cd view. As you can see, the node reference field is available from the drop-down menu.

http://www.brokebust.com/_work/views_fusion_cck_002.jpg

Once the fused view is created, however, it doesn't mention the node reference field any more :(

http://www.brokebust.com/_work/views_fusion_cck_003.jpg

Sure enough if you go and view it it's just a massive SQL error message.

Can anyone help me out? Any ideas? I'm not even sure really where to start fixing this.

Note: I have tried this after patching the module with patch version 47_1 then 47_2 then 1.5 AND I also tried it after reinstalling the module and just patching it with 1.5.

bestknight’s picture

Try my #43 implementation - just those mentioned - no prior patches implemented.

aren cambre’s picture

Title: views fusion support for nodereference - errors and failure » views fusion support for nodereference
Category: support » feature

revet ecoluke's changes to the issue.

socialnicheguru’s picture

subscribing

socialnicheguru’s picture

I got a large number of SQL errors. If you are having sql issues remove the sort from both views. It took me a day to figure out that is what it was for me.

Chris

bestknight’s picture

StatusFileSize
new5.45 KB

Following on from comment #43

applied #20 patch manually to CCK 5.x-1.7 (of course lines in the module have changed so patch cannot be applied automatically - well I don't even know HOW to apply the patch automatically in the first place), using Views 5.x-1.6 and Views Fusion 5.x-1.2 and again it seems to work.

reminder - I have previously changed column "uses" of views_fusion table to length 128 from 32, in accordance with http://drupal.org/node/145397 comment #5

Attached is the patched nodereference.module of CCK 5.x-1.7 (zipped)

micheeb’s picture

StatusFileSize
new1.98 KB

Here's a patch file generated from the nodereference.module file in comment #50

Cheers!

ratnesh aarohi’s picture

i think i need to subscribe to this - but
I have never applied a patch before
1 - how does one apply this (or any) patch?
2 - and to which file?
sorry i hope this is the correct place to ask this question
thanks
ratnesh

scedwar’s picture

kehan’s picture

subscribing

kmetz’s picture

also subscribing

liquidcms’s picture

StatusFileSize
new1.96 KB

i think this is patch for cck 1.9

drew reece’s picture

Any ideas why this hasn't been committed to the module yet?

It makes the nodereference.module very useful (at least for me), it seems odd that people have to re-roll the patch for each cck version.

Can people post if it works/breaks for them.

It works for me.

drew reece’s picture

The patch in #56 applies cleanly to 5.x-1.9 and works with views fusion.

Satori42’s picture

Yes. The patch in #56 applies cleanly to 5.x-1.9 and works with views fusion.

bneel’s picture

The patch #56 also works for 5.x-1.10 with views fusion.

aren cambre’s picture

Since this is a feature request, doesn't it get applied to the newest line first then backported to older lines?

bomarmonk’s picture

Subscribing...

theruslan’s picture

Subscribe.

aren cambre’s picture

Version: 5.x-1.x-dev » 7.x-2.x-dev

Changing version based on #61.

drew reece’s picture

The patch here is for Drupal 5.x not 7.x I'm not sure you should be changing the Version on this thread, especially since no one answered your question in post #61 Aren.
Maybe you are correct, I just think it would put me off testing this patch if the thread said it was for 7.x, I don't do development work. Have you tried this patch with 7.x?

aren cambre’s picture

Let's see what an admin says. #61 is my experience with almost all modules.

joachim’s picture

Version: 7.x-2.x-dev » 5.x-1.x-dev

The version should be 5.x.
There won't be a patch on 7.x or even 6.x for that matter, as views_fusion is not available for 6 or beyond: see http://drupal.org/project/views_fusion for details.

tortoise’s picture

I applied the patch from #56 to nodereference 5.x-1.10, but the nodereference options aren't showing up in the views fusion admin page. When I go to the "Fusion" tab within Views admin, the "using" dropdown menu gives me parent-child and child-parent relations for nodefamily (built-in with Views fusion) and node relativity (from a patch to that module), but nothing for nodereference.

mroswell’s picture

Try clearing the views cache, at admin/build/views/tools

Also, the regular cache, easily cleared with the Devel module.

I think the first should do it, though.

tortoise’s picture

Actually, it turned out to be a very foolish mistake on my part -- I hadn't defined any noderefence fields, so there weren't any such relationships to list. Now it works as intended.

karens’s picture

Status: Needs review » Closed (won't fix)

A very old feature request for D5, won't do anything with this now.