Not sure if this is the best way to go about this, but I was trying to get the tid that was created from the node available as a field in node views, and the nid of the node that created the term available as a field in term views.

I also took out the nid from node views since the node base table already provides nid, and tid from term views since term_data already provides tid for those.

The nice thing about this is that you can now create term views with a field that links to the node that created it, or a node view where a field links to the term it created.

CommentFileSizeAuthor
#12 t2n.patch402 byteshawleyal
nat_views_tid_field.patch2.2 KBq0rban

Comments

Zen’s picture

Component: Code » Views Integration
marcvangend’s picture

Excellent patch, I needed this, thank you q0rban! I haven't found any bugs so far, if I do, I'll let you know.

anantagati’s picture

Version: 6.x-1.1-beta3 » 6.x-1.x-dev
Status: Needs review » Fixed

Attached patch seems to remove support for arguments.

I am closing this issue as there was recently committed patch #624640: Add a views relationship to the NAT node to 6.x-1.x-dev. It enables you to use NAT relationship and thus be able to access NAT node data in view.

hawleyal’s picture

I can't see the NAT TID or NAT NID relationships, arguments, or fields in a terms view (items of type Term).

There's not even a NAT group.

Am I missing something?

anantagati’s picture

Did you installed latest dev version?

If you have problem, please open new support issue.

hawleyal’s picture

Status: Fixed » Needs work

Specifically.

I have a generic term view.

They query is:
SELECT term_data.tid AS tid, term_data.name AS term_data_name, term_data.vid AS term_data_vid FROM term_data term_data

I'd like to add the NAT NID to the query:
SELECT term_data.tid AS tid, term_data.name AS term_data_name, term_data.vid, nat.nid as nat_nid FROM term_data term_data LEFT JOIN nat nat ON term_data.tid = nat.tid

Thoughts?

hawleyal’s picture

yes, latest dev version.

I'm staring at the code.

All join on node, none on term.

Shouldn't it be join on term_data, table nat, left field tid right field tid, result field nid?

anantagati’s picture

If you can post patch, I can look at it and commit it.

hawleyal’s picture

geez.

never developed a mod.

don't know the docs on api structure.

i suppose i could break my own site without too much trouble.

anything special i need to know about editing nat.views.inc?

Just edit, upload, use?

Flush caches?

Run update?

anantagati’s picture

Of course you don't play with live site.

hawleyal’s picture

well, not production yet.

still just R&D.

hawleyal’s picture

Status: Needs work » Needs review
StatusFileSize
new402 bytes

Okay. Guess it was simpler than i thought.

Here's the code.

// add nat node to term view (t2n)
$data['nat']['table']['join']['term_data'] = array(
 'left_field' => 'tid',
 'field' => 'tid',
);

Patch attached.

anantagati’s picture

Status: Needs review » Fixed

Thank you for the patch. Committed in 6.x-1.x-dev.

Status: Fixed » Closed (fixed)

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

drewvancamp’s picture

I'm beating my head trying to provide a field in my view that represents the NAT-related term for each listed NAT-related node. This is a node view because I'm pulling in CCK from a NAT-created term's associated node. The only term-related field I need is the path to the term page so I can make the node content navigate the user to the NAT term's page (rather than than the NAT node).

What I'm working with is a hierarchy of NAT nodes/terms (a product catalog), e.g. Apparel > Ladies Apparel > Ladies Vests > Ladies Premium Vests. On each term page, which is overridden using Panels and Views, I'm showing several views. One displays content from the NAT node that belongs to the term we're looking at. Another shows all products associated with the viewed term. The tough one involves showing all subcategories of the category we're looking at which works fine and basically pulls up all nodes that are associated with the current term (using an argument) as their parent term (using a relationship); this gives me the child categories related to the current term. However, I want these child categories to link directly to the associated term page, but the only fields I seem to be able to produce are links either to the NAT-related node or the parent term. I don't see how to display the NAT-created TID related to the NID that's listing by way of views.

The aforementioned use of NAT relationships only seems to provide me with the NID for the currently viewed term. Instead I'm trying to show the TID for the child nodes of the current term. And my head is spinning as a result...

Could I be missing something obvious or perhaps just going about this the wrong way?

(Please don't bother advising the use of Ubercart or any other catalog-related module. I'm sticking to Views-Panels-Taxonomy-CCK solutions to maximize compatibility with other modules and to give myself complete control and customization over the catalog pages.)

Hope someone will be able to help me. I've tried to find tutorials and NAT-Views documentation and I've looked through similar discussions and issues (this has been about as difficult as it was for me to catch on to the use of Views arguments and relationships).

Thank you for your time,
- Drew