relatedContent is excellent, well done.
How can I only display the body of the related node instead of the full node?
In relatedcontent.tpl.php I've tried adding
print_r($content);
after
echo content;
but it gives me the whole node again. I don't know enough php or Drupal to go any further.
Thanks
Comments
Comment #1
j0hn-smith commentedI found issue #215123: Title only listing of related nodes in settings where you suggest some sudo code, I'll try that with with $body instead of $title.
Comment #2
TBarregren commentedYes, the pseudo code in #215123 is a good starting point to accomplish what you want. I included a small but powerful API in RelatedContent just for that purpose. The interesting function is
As described in the modules handbook,
relatedcontent()returns an array whose keys are the names by which the output should be grouped according to$output_grouped, i.e. names of content types, authors, views or'all', and whose values are also arrays of the return values of calling$content_functionwith the node objects with related content of$nodeas the first argument and$content_function_argsas the following arguments.For an example, calling
returns something similar to this:
where
$nodes[#]is the node object next in turn, according to its source view's sort order, whithin its group.The only argument that is mandatory is $node, which is the node id or node object of the node whose related content is to be returned. The default value of
$output_groupedisfalse, which results in a single group called'all'. The default value of$content_functionis a function that merely returns the node object itself. The default value of$content_function_argsis en empty array, i.e. no arguments.If you are not using the API, but just rely on the default behavior of the module, that corresponds to following call:
where
$output_groupedand$output_teasersis set according to the settings of the content type of the node given by$node. The functionnode_view()used as the content function, is Drupal's standard function for generating the display of a node as either a full page or a teaser.The fact that RelatedContent uses
node_view()as it content function implies that the styling of the bodies or teasers of the related content themselves must be done through the regular theming of nodes, i.e. by overridingtheme_node()or changes innode.tpl.phpfile.The documentation of the function in source code documentation of
relatedcontent()gives some examples of how it can be used. See also the documentation.Comment #3
j0hn-smith commentedWow, thanks for replying so fast.
I know that the API can be used to achieve what I want but even though your code is commented perfectly in the module source code, my programming skills aren't sufficient to understand anything but step by step examples, eventually I get there by trial and error. I must learn about using API's.
For others needing similar functionality here's a copy of my post with working code originally posted here #215123: Title only listing of related nodes in settings (apologies duplicating the issue).
Comment #4
TBarregren commentedI have expanded your example in this comment http://drupal.org/node/215123#comment-720582.
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.