CMS & WordPress
wolf_22 — 2012-08-01T16:21:58-04:00 — #1
Here's what I have:
Drupal 6.x with 3 content types:
All three have their own template files and I can access everything in the $node object. I can also use things like node_load() to load other nodes, views_embed_view() to embed views, etc. I can also pass values into views_embed_load() in order to create conditional views. A very handy thing to do, I might add...
Here's the problem:
I'm having a hard time generating links to Con1 content from within Con3 content if and only if Con2 content is node-referenced from a single Con1 CCK field using nothing more than the current Con3 content's $node->nid.
I need help:
Would anyone have any suggestions about how to go about achieving this? I thought the reverse node reference module would help, but I can't even tell if it's doing ANYTHING... It seems to be a somewhat flaky module as far as I can tell but I'm assuming this is just because I don't know how to use it within Views yet. I then thought I might be able to use the Con2 NIDs from within Con3 as I have already used node_load to load their objects into my Con3 template, but the problem is that this is somewhat static--there's no way to determine if something has been node-referenced or not (which is why I tried using that module above).
Any insight or feedback is appreciated.
awasson — 2012-08-01T20:34:18-04:00 — #2
It's the end of the day so I might be a bit thick but can you explain what is is that you want to do?
You've got 3 content types and you're trying to reference content from one type into another somehow... Now I'm intrigued and I'll help if I can but I need a little more info.
wolf_22 — 2012-08-02T08:29:42-04:00 — #3
Hi Andrew and thanks for responding. I'll try to explain this from another angle that might make a little more sense:
Let's say we have 3 content types of the following (which all use their own template files):
- Products Page
- Application Page
- Organization Page
Now let's say that we want to include links to product pages on the organization pages if and only if each product page node-references an application page that is being node-referenced from an organization page (including links to product pages if the product pages are node-referencing the same application pages that the organization pages are node-referencing).
Does that help? The rationale behind all this mess is that a product can encompass multiple applications and we have organizations which have multiple products but from everything, we're just trying to avoid duplicating labor because we can do a simple node-reference field from the organization page for product pages, but this constitutes a manual entry. We want this to be programmatic (automatic) by somehow making the organization template file determine which application pages have been node-referenced and based on that finding, determine whether or not those application pages being node-referenced from organization pages == those being node-referenced from product pages. If they do, then this would mean that that the product page is a product belonging to the organization.
(I hope that clears it up a bit. If we have to, we can go with the node-reference field on the organization template, but again, we're just trying to make everything as automatic as possible.)
wolf_22 — 2012-08-02T15:43:17-04:00 — #4
This one must be a biggie for everyone... Well, rest assured: I found a solution using nothing more than Views.
Here's how it works:
1.) Create a default view. Give it a name, etc. Nothing special here.
2.) You will use the fields area to link to the final node you wish to output links to. Keeping that in mind, if content_type_1 needs links to content_type_3 if and only if content_type_2 is being referenced by both content_type_1 and content_type_3, then you will use the relationships area to create a relationship of the CCK field that ties everything together (the node_reference field). Make sure the relationship is required, too.
3.) I decided to embed my view (put the specific view call inside the template file with views_embed_view('<name of view>', 'default', $views_argument), so this meant that I needed the argument area to create a views argument of the same type as the node_reference field I used in the previous step. I set this argument to be of the content_type_2 type, allowed it to validate for user access, and also allowed multiple arguments (which is imperative if using an array).
4.) I then sorted in ascending order and filtered against content_type_3 (making sure to also create a filter of being published).
Worked like a charm using Drupal 6.x, Views CCK w/ Node Reference 6.x-2.9, and Views 6.x-2.16 on a hot, dry, and somewhat muggy summer day with 1 grande iced-coffee from Starbucks...
awasson — 2012-08-02T16:14:08-04:00 — #5
I'm glad you figured it out... I often figure out my solutions while composing a posting on SP myself... It forces me to think it through thoroughly.
I thought it would be possible using views; Oh how I love views, the make me look like a genius. I haven't had time yet to review your explanation but I'll do that this afternoon.
cms_dude — 2012-08-03T21:53:07-04:00 — #6
I think you just turned my brain in to a pretzel.
This post should come with a warning message. I might have to sue. Makes me think of a Drupal T-shirt I saw: "I don't know the question, but the answer is views."
awasson — 2012-08-04T00:53:20-04:00 — #7
Yeah, that is some crazy Ninja, Voodoo stuff you're working on Wolf_22.... I'm still not quite sure exactly what you're doing but I'm glad you got it figured out... I've been thinking about it off and on and the first thing I would try is Taxonomy to act as a link but I don't think it would be flexible enough so then I'd try something way out there like Organic Groups. I've done lots with CCK and Views but I don't think I've done anything quite like that.
PS: CMS Dude, I want one of those t-shirts
mittineague — 2014-09-21T18:47:26-04:00 — #8
This topic is now archived. It is frozen and cannot be changed in any way.