Hello to all,

This is my first issue report, so sorry if I'm being scholastic...

Steps I followed:
1. created a view and tested
2. gone to /admin/content/node-type/myNodeType >>> related content configuration >>> settings and filled the form as follows
Length of node table: 10
Related content in teasers: exclude
Where to display: end
What to display: Teasers
How to display: Grouped by view
3. Gone to node page >> tab related content and checked some of the related nodes

Expected Results:
I expected the related content listed at the end of the node

Actual Results:
the list is always on top.
If I check where to display either "not at all" or "beginning" the behaviour is correct, the list disappear or stay on top

Did I miss something? Is there a way to solve this?

Thank you in advance
Simone (Italy)

Comments

peter-boeren’s picture

StatusFileSize
new148.47 KB
new130.09 KB
new114.77 KB

Hi Simone,

I have tried to reproduce you bug but I was unable. I have created the same set up as described in you post. I have added a few screenshots to show you what I see.

screenshot: editing of the node type page
screenshot 1: show the node with the local task 'related content'
screenshot 2: node view showing the related content at the end.

First recheck you settings to make absolutely sure. If you are then the next step is to debug. The magic of 'beginning - end' happens in the function function _relatedcontent_node_view(&$node, $teaser, $page) { This can be found in the file relatedcontent.module

if you print the variable $output_placing you can see which case will be used. Compare this value with you settings. All settings are saved in the variable table.

I hope this helps.

midmood’s picture

Hi, thanks for your time.

Yes: setting are ok, more than double check

I'd be glad to help debugging but... I'm more a configurator than a coder, so I'm not able (practically) doing this.

if you print the variable $output_placing you can see which case will be used. Compare this value with you settings. All settings are saved in the variable table.

If this feedback is important to you to debug the module, I'm helping happily, but I'm sorry to ask you sort of a workflow.

Have a nice day
Simone (Italy)

peter-boeren’s picture

Okay, well it is quit easy. Open the file 'relatedcontent.module' in an editor (http://en.wikipedia.org/wiki/List_of_PHP_editors)

Search for line 350 which should start with "function _relatedcontent_node_view(&$node, $teaser, $page) {". Below is the function and add the print-statement ("print $output_placing;") in the code to debug the settings. After saving the new code, you should visit a node with related content. On top of the page the output of the print statement will appear. It should say 'beginning' of 'end'. Compare this to your settings.

/**
 * A node is being viewed.
 */
function _relatedcontent_node_view(&$node, $teaser, $page) {
  // Get settings.
  $output_placing = relatedcontent_variable_output_placing($node->type);
  $output_teasers = $teaser || relatedcontent_variable_output_teasers($node->type);

  $output_grouped = relatedcontent_variable_output_grouped($node->type);
  // Abort if output isn't wanted in general, or when viewing a teaser.
  if (!$output_placing || $teaser && relatedcontent_variable_exclude_teasers($node->type)) return;

  // Get the related content. Abort if the node lacks related content.
  if (!$node->nodes || !($output = _relatedcontent($node, $output_grouped, 'node_view', array($output_teasers)))) return;

  // Theme the related content.
  $output = theme('relatedcontent', $output, $output_grouped, $node->type, $teaser, $page);
  $node->content['relatedcontent']['#value'] = $output;
  
  print $output_placing;
  // Add the themed output to the node's body.
  switch ($output_placing) {
    case 'beginning':
      //$node->content['body']['#value'] = $output . $node->content['body']['#value'];
      $node->content['relatedcontent']['#weight'] = $node->content['body']['#weight'] - 1;
      break;
    case 'end':
      //$node->content['body']['#value'] = $node->content['body']['#value'] . $output;
      $node->content['relatedcontent']['#weight'] = $node->content['body']['#weight'] + 1;
      break;
  }
}
midmood’s picture

ok, all done:

the function print statement return "end", but the selecteed list of related content is at te beginning
I checked the settings again in the content type. It's on "end" as well.

peter-boeren’s picture

Interesting,

do you have a clean install like me of is the a website with a lot of other active modules? It is possible for other modules/themes to alter the way content is show.

1) choose an other template: Choose garland, bluemarine or something other very basic. If the problem persists than it is not theme related.

2) If you have a lot of active modules try a clean install. If the problem doesn't occur anymore then one of the active modules is interacting.

kind regards

Peter

midmood’s picture

case 1 >> garland >> same behaviour (so, no interactions with genesis theme)

case 2 >> garland & disabling the only module hich actively impact on the content type (addthis.nodule) >> same behaviour

Anyway, this troubleshooting was *very* useful, even for future problems, I feel the step forward :-)

And, with the "step forward hat" on, i truly believe it's a module interaction issues. The site we're talking about is a test one. I installed and uninstalled many times many modules.

I think it's impossible to go back to the root of the problem, do you?

Thank you very much, Peter

Simone

peter-boeren’s picture

If it is a test website you might send me a dump of the database and the website. Then I can reproduce it on my local machine. A solution to your problem may prevent more issue posts for me. ;)

Peter

peter-boeren’s picture

Assigned: Unassigned » peter-boeren
peter-boeren’s picture

Status: Active » Fixed
StatusFileSize
new251.74 KB

The problem is that with CCK you are able to alter the weights of elements. This can be seen at $node->content['#pre_render']. There the function 'content_alter_extra_weights' is called. So to make your website work the relatedcontent should be aware of the fact that CCK can be installed. This is shown in the code below. This code will soon finds it way into the related content package. Attached is also a screenshot where the relatedcontent is lower than the body as it supposed to be.

/**
 * A node is being viewed.
 */
function _relatedcontent_node_view(&$node, $teaser, $page) {
  // Get settings.
  $output_placing = relatedcontent_variable_output_placing($node->type);
  $output_teasers = $teaser || relatedcontent_variable_output_teasers($node->type);

  $output_grouped = relatedcontent_variable_output_grouped($node->type);
  // Abort if output isn't wanted in general, or when viewing a teaser.
  if (!$output_placing || $teaser && relatedcontent_variable_exclude_teasers($node->type)) return;

  // Get the related content. Abort if the node lacks related content.
  if (!$node->nodes || !($output = _relatedcontent($node, $output_grouped, 'node_view', array($output_teasers)))) return;

  // Theme the related content.
  $output = theme('relatedcontent', $output, $output_grouped, $node->type, $teaser, $page);
  $node->content['relatedcontent']['#value'] = $output;
  
  // Add the themed output to the node's body.
  switch ($output_placing) {
    case 'beginning':
       if (module_exists('content') && $node->content['#content_extra_fields']['body_field']['weight']) {
        $node->content['relatedcontent']['#weight'] = $node->content['#content_extra_fields']['body_field']['weight'] - 1;
      }
      else {
        $node->content['relatedcontent']['#weight'] = $node->content['body']['#weight'] - 1;
      }
      break;
    case 'end':      
      if (module_exists('content') && $node->content['#content_extra_fields']['body_field']['weight']) {
        $node->content['relatedcontent']['#weight'] = $node->content['#content_extra_fields']['body_field']['weight'] + 1;
      }
      else {
        $node->content['relatedcontent']['#weight'] = $node->content['body']['#weight'] + 1;
      }
      break;
  }
}
midmood’s picture

Thank you very much.
I'm adding your code and looking forward for the corrected version.

Simone

Status: Fixed » Closed (fixed)

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