refer/retrieve/save grandparent in child node without parent's node load
Couldn't think of an easier subject line :-) I have three node types A -> B -> C A <- B <- C where A refers B and B refers C (and there's CNR for backwards). Now when displaying content from C, i would want to display A's titles (atleast). Is there a way where I can refer A as well in C because of the reference to B? This so that while displaying C, I don't have to load B's entire content and then retrieve A. C can have unlimited number of references to B. So loading B within C is not such a good idea. I hope you are not at c when reading this :-) All help really appreciated. Regards - Ben
The answer to resource intensive processes is usually caching of some kind. For your case, you might consider using the computed_field module to add a "ref_a" field on C, which gets stored in the content_type_C table. By default, this field is only updated when a C is saved. If your workflow requires it, you can use Node API or Rules to update the appropriate C nodes whenever a B (or A) node is updated, basically performing node_save(node_load($nodeid_of_c)). Ted On 3/15/2011 12:16 PM, Benjamin Jacob wrote:
Couldn't think of an easier subject line :-)
I have three node types A -> B -> C A<- B<- C
where A refers B and B refers C (and there's CNR for backwards).
Now when displaying content from C, i would want to display A's titles (atleast). Is there a way where I can refer A as well in C because of the reference to B? This so that while displaying C, I don't have to load B's entire content and then retrieve A. C can have unlimited number of references to B. So loading B within C is not such a good idea.
I hope you are not at c when reading this :-)
All help really appreciated.
Regards - Ben
That looks like some work :-) Thanks Ted. Will try it out. --- On Tue, 3/15/11, Ted <ted-drupalists@webfirst.com> wrote:
From: Ted <ted-drupalists@webfirst.com> Subject: Re: [support] refer/retrieve/save grandparent in child node without parent's node load To: support@drupal.org Date: Tuesday, March 15, 2011, 5:09 PM
The answer to resource intensive processes is usually caching of some kind. For your case, you might consider using the computed_field module to add a "ref_a" field on C, which gets stored in the content_type_C table. By default, this field is only updated when a C is saved. If your workflow requires it, you can use Node API or Rules to update the appropriate C nodes whenever a B (or A) node is updated, basically performing node_save(node_load($nodeid_of_c)).
Ted
On 3/15/2011 12:16 PM, Benjamin Jacob wrote:
Couldn't think of an easier subject line :-)
I have three node types A -> B -> C A<- B<- C
where A refers B and B refers C (and there's CNR for backwards).
Now when displaying content from C, i would want to display A's titles (atleast). Is there a way where I can refer A as well in C because of the reference to B? This so that while displaying C, I don't have to load B's entire content and then retrieve A. C can have unlimited number of references to B. So loading B within C is not such a good idea.
I hope you are not at c when reading this :-)
All help really appreciated.
Regards - Ben
-- [ Drupal support list | http://lists.drupal.org/ ]
Hi, I worked around this issue. Thankfully I have to only display grandparent's info and not manipulate it. So for this issue, Views comes to the rescue. . created a View block with filter as Node Type B . Added View argument as Node ID(s) which must be of type B . Added Fields for output of B's title and also B containing A's ref (and hence A's title too). Now in C's tpl.php, I embed this view using: e.g. $Bnids = "100+101+203"; // multiple nids print views_embed_view("B_to_A_view_display", "block_1", $Bnids); And voila, I get a nice table of the required fields in C. Love drupal.. and every day I discover new ways of using Views. As they say, I'm loving it!! cheers - Ben --- On Thu, 3/17/11, Benjamin Jacob <ben4asterisk@yahoo.com> wrote:
From: Benjamin Jacob <ben4asterisk@yahoo.com> Subject: Re: [support] refer/retrieve/save grandparent in child node without parent's node load To: support@drupal.org Date: Thursday, March 17, 2011, 3:03 PM
That looks like some work :-)
Thanks Ted. Will try it out.
--- On Tue, 3/15/11, Ted <ted-drupalists@webfirst.com> wrote:
From: Ted <ted-drupalists@webfirst.com> Subject: Re: [support] refer/retrieve/save grandparent in child node without parent's node load To: support@drupal.org Date: Tuesday, March 15, 2011, 5:09 PM
The answer to resource intensive processes is usually caching of some kind. For your case, you might consider using the computed_field module to add a "ref_a" field on C, which gets stored in the content_type_C table. By default, this field is only updated when a C is saved. If your workflow requires it, you can use Node API or Rules to update the appropriate C nodes whenever a B (or A) node is updated, basically performing node_save(node_load($nodeid_of_c)).
Ted
On 3/15/2011 12:16 PM, Benjamin Jacob wrote:
Couldn't think of an easier subject line :-)
I have three node types A -> B -> C A<- B<- C
where A refers B and B refers C (and there's CNR for backwards).
Now when displaying content from C, i would want to display A's titles (atleast). Is there a way where I can refer A as well in C because of the reference to B? This so that while displaying C, I don't have to load B's entire content and then retrieve A. C can have unlimited number of references to B. So loading B within C is not such a good idea.
I hope you are not at c when reading this :-)
All help really appreciated.
Regards - Ben
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
participants (2)
-
Benjamin Jacob -
Ted