RC Block Empty, but CCK field has entries

muckermarc - October 8, 2009 - 15:42
Project:Relevant Content
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Hi,

I logged a similar issue on this before: http://drupal.org/node/441992 - I'm now working on a different Drupal site, but having a similar issue and would be grateful if you can look at this again.

I have two content types "Type A" and "Type B" and a single taxonomy. Nodes are created of both "Type A" and "Type B" and are tagged accordingly with tags from the taxonomy.

I have two blocks - "Relevant Content A" which shows matching nodes of "Type A", and "Relevant Content B" which shows matching nodes of "Type B". The "Relevant Content A" block is set up to display only on nodes of "Type B" and vice-versa.

Only one of the blocks will ever appear - i.e. on nodes of "Type B" I will see "Relevant Content A", but I'll never see the block "Relevant Content B" on nodes of "Type A".

I dropped it some of the debug code listed in other issues here, and on the pages with the block successfully appearing, I can see the $terms array. On those nodes where the block does not appear, $terms is an empty Array ().

I downloaded your latest Dev version and played with the new CCK field. Interestingly enough, the CCK field is working fine on both types of node.

Any ideas?

Cheers,

Marc

#1

muckermarc - October 14, 2009 - 12:11

Hi,

Did some more digging on this and I think the issue could be in the function relevant_content_get_page_terms() in the .module file.

On my problematic pages (i.e. those where the CCK works, but the block doesnt), this function is called by the CCK and passes through the current $node. In the block, this function is called with no parameter, and so it tries to work out the current node.

I can get as far as this elseif block:

  elseif (arg(0) == 'node' && is_numeric(arg(1))) {
    $node = menu_get_object();
    $terms = taxonomy_node_get_terms($node);
        // some debug code:
echo('have node:' . $node->nid);
  }

When I echo the nid, I get the current node's parent's nid, not it's own nid.

Seems to be the menu_get_object() function is returning the parent node, rather than the current node - possibly because the current node isn't in a menu?

Any ideas?

Marc

#2

muckermarc - October 20, 2009 - 11:22

Hi again,

This "feature" does seem to be menu related.

I'm using the Node Hierarchy module, and have the RC block set up to display on child pages under a parent page.

If I put a link to the parent page into the Primary Links menu - then the RC block doesn't display.

If I delete the link to the parent page from the Primary Link menu - then the RC block does display.

Cheers,

M

#3

muckermarc - October 20, 2009 - 11:41
Status:active» needs review

As far as I can tell, it's the Node Hierarchy module that was causing the issue the RC block, and specifically the menu_get_object() function.

I updated the Node Hierarchy Module to the latest development version and this *seems* to have solved the problem.

See http://drupal.org/node/461544 for more info.

Cheers,

M

 
 

Drupal is a registered trademark of Dries Buytaert.