Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To display more than titles with nodereferences, maybe we could leave it to a theme function?
In nodereference_field_view_item(), we have this:
return l($referenced_node->title, 'node/'. $referenced_node->nid)
Instead, maybe we could have something like:
return theme('nodereference', $referenced_node);
$referenced_node being a full node object, the theme could choose to display whatever node data it wants.
If anyone likes this idea, I could roll a patch.
Comment | File | Size | Author |
---|---|---|---|
#13 | nodereference_load_full_node_1.patch | 1.82 KB | alex_b |
#12 | nodereference.load_full_node_0.patch | 17.38 KB | sun |
#11 | nodereference.load_full_node.patch | 3.07 KB | sun |
#7 | nodereference.module_4.patch | 717 bytes | David Lesieur |
Comments
Comment #1
ashtonium CreditAttribution: ashtonium commentedPersonally, I was hoping that this was what nodereference did when I first experimented with it.
Comment #2
yched CreditAttribution: yched commentedI think it might be useful to pass the type of the node whose node reference field you're viewing, along with the node object itself ?
You might want to theme the referenced nodes differently for diferent content types
(not sure that info is available in nodereference_field_view_item(), though)
Comment #3
KarenS CreditAttribution: KarenS commentedWe definitely need the content type. I forgot about that one, but if you send the whole node you'll get the type, too.
Comment #4
yched CreditAttribution: yched commentedKaren : not sure i was clear
I meant passing to the theme function the type of the node having the reference (left side of the 'relation'), along with the referenced node itself (right side)
maybe that is what you understood...
I have a hint that we might need to define a vocabulary here :-)
Comment #5
KarenS CreditAttribution: KarenS commentedAha, no I did not understand you. It sure is confusing keeping 'referenced' and 'referenced by' nodes straight. Yes, I agree that the content type of both needs to go to the theme because it could make a difference in how the data should be presented.
Comment #6
David Lesieur CreditAttribution: David Lesieur commentedGood idea! We could pass the $field to the theme function. It has a 'type_name' member which is the type of the node containing the field.
Comment #7
David Lesieur CreditAttribution: David Lesieur commentedHere's the small patch. If this gets committed, I'll update the patch in http://drupal.org/node/60756.
Comment #8
David Lesieur CreditAttribution: David Lesieur commentedComment #9
StevenSokulski CreditAttribution: StevenSokulski commentedI'm a bit lost in terms of how to implement this. Could somebody throw together a quick step-by-step on how to make this thing work. I've already got the patch in place but unsure how to use it.
Comment #10
David Lesieur CreditAttribution: David Lesieur commentedPlease do not hijack feature requests into support requests. We can never get the thing committed if it is filed as a support request.
This patch adds a new theme function. Theme functions can be overridden in your theme. You can find how to do this in the handbook. See here and there.
Comment #11
sunI've been working on this feature, too. IMHO it doesn't make sense to only theme a referenced node. Each content type needs its own styling. I'd like to propose a new option for each node reference to select whether the referenced node should only be listed (default) or completely loaded into the cck node object.
This was the solution for me. It could be extended to select which fields of the referenced node type should be loaded in the future.
Attached patch integrates this option into nodereferences.module which needs a slightly customization of content.module.
Comment #12
sunSorry, don't have enough time now - this reworked patch includes the patch for nodereference backlinks (node referrers).
It loads the referenced node object always, since this would be done twice otherwise.
Comment #13
alex_b CreditAttribution: alex_b commentedThis small patch makes use of hook_field_formatter().
It allows you to chose on the Display fields tab wether you want to reference a node by showing the plain title, the linked title, the node teaser or the node body.
You can chose different presentation types for the teaser and the body view of the embedding node. E. g. you can show the teaser of the embedded node in the teaser view of the embedding node and you can show the full node view of the embedded node on the full node view of the embedding node.
It also passes the $field variable to the theming layer, which opens additional theming options on embedded nodes in node.tpl.php.
I rolled this patch against the latest DRUPAL-5 version of nodereference.module (r1.39.2.12).
alex
Comment #14
appel CreditAttribution: appel commentedSubscribing.
Comment #15
mcreature CreditAttribution: mcreature commentedSubscribing.
Comment #16
sunPatch in #13 looks solid and clean to me. If that one works, I'd go for that - didn't have the time to test yet.
Comment #17
yched CreditAttribution: yched commentedLooks ok - the only thing that bugs me is the
$referenced_node->field = $field;
part - not exaclty sure why, but I'm kind of reluctant... I'll try to give it a closer look.Comment #18
yched CreditAttribution: yched commentedAlso look http://drupal.org/node/91792 for a more general discussion about this - views output is definitely the way to go, but the implementation is still not resolved.
Comment #19
guardian CreditAttribution: guardian commentedsubscribing
Comment #20
ktnk CreditAttribution: ktnk commentedHi,
In order to finalize my site structure, I need to try out the patch above (http://drupal.org/node/65133#comment-191144)
Will it work with my current version of nodereference.module,v 1.39.2.17 2007/03/05 ?
Will this patch be updated for the the latest release? Rolled in to the next cck release?
Should I just replace my nodereference.module file with your patch and run update.php?
Please answer asap,
thanks,
ktnk.
Comment #21
alex_b CreditAttribution: alex_b commentedktnk,
Is actually an interesting question wether the patch in #13 is still applicable - give it a go:
http://drupal.org/patch/apply
Comment #22
yched CreditAttribution: yched commentedI committed a slightly reworked version of #13.
It adds both 'referencing_node' and 'referencing_field' properties to the referenced node before rendering. Not sure where we should document this feature, though.
Comment #23
(not verified) CreditAttribution: commented