I'm using Submenu Tree to display the parent menu (as menus) before content, so I set weight = 0 on the node form and it worked as expected. The module was working perfectly on my site, but suddenly I created a node in which the module misteriously showed the menu after the content.

I just thought that I had forgot to set "weight = 0", but that's was not the case. Even if I put weight to the minimum value (-10), the menu is always being shown after the content.

I did a few tests, and discovered that if I also enable "Enable siblingmenu trees for this node" them the (parent) submenu tree is shown before content as expected (though the sibling menu is being shown after content, even if I use weight = 0 for the sibling).

I'm scratching my head for an hour or so and found no solution. There already are dozens of nodes on the site where the menu is being shown on the right place. There's nothing particular about this new node -- it's just a plain "page" node.

Did anybody have seem this already? Any clues?

Comments

bengtan’s picture

Nope, haven't seen it :)

But you can answer some questions for me and help me diagnose.

Does this only affect one page node, or all page nodes?

Are you using CCK and CCK fields in your page nodes?

Are you using any other modules which may affect the way a node is displayed?

Are you using a custom template for your page nodes? ie. a node-page.tpl.php in your theme?

flaviovs’s picture

Does this only affect one page node, or all page nodes?

The module behaved as expected in half-dozen nodes.

Then suddenly for one node it didn't show the menu on the right location. All other nodes still ok.

I've just created a new node/menu structure just to check -- the menu is still not being shown on the correct location on new nodes. *sigh*

Are you using CCK and CCK fields in your page nodes?

No. Just plain title/body fields.

Are you using any other modules which may affect the way a node is displayed?

Well... let's see... Menu Settings per Content Type maybe? Or perhaps Local Menu?

These are the only two node/menu related modules on my install (apart CCK, various CCK custom fields, Views, and another bunch of unrelated modules).

Are you using a custom template for your page nodes? ie. a node-page.tpl.php in your theme?

No.

-x-x-

If you need more help to solve this issue, let me know. Since the site is not in production yet, I'm willing to change the module and add debug code (I have some experience in PHP programming) to help us figure what heck is going on.

bengtan’s picture

As a quick test, do you want to just disable Menu Settings per Content Type and Local Menu and see if it affects the issue? It shouldn't, but stranger things have happened.

Otherwise, yes, maybe some debug code is in order.

Or would you be willing to give me a database dump of your site? Then I can try to recreate on my own system.

tronathan’s picture

I have observed that the siblingmenutree_weight is an UNSIGNED integer, which means values less than 0 will not save when saving/updating a node:

siblingmenutree_weight int(10) UNSIGNED

In the module,

function submenutree_schema() {
  $schema['node_submenutree'] = array(
    'description' => t('The base table for submenutree'),
    'fields' => array(
      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
      'submenutree_enable' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
      'submenutree_title' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
      'submenutree_display' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
      'submenutree_weight' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
      'siblingmenutree_enable' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
      'siblingmenutree_title' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
      'siblingmenutree_display' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
    <b>  'siblingmenutree_weight' => array('type' => 'int', 'unsigned' => TRUE</b>, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10')),
    'primary key' => array('nid'),
  );
  return $schema;
}

The weight column is in fact UNSIGNED. This appears to be a bug. Can anyone confirm?

flaviovs’s picture

It looks like the bug is related to this unsigned issue.

Today I spent some time debugging the problem. By default, the 'body' content in the $node structure has an weight 0. Since the minimum 'submenutree' weight is 0 (due to the unsigned bug), the sorting of contents that are done inside Drupal to render node body may be just not touching the two items when sorting.

If I manually set $weight = -1 in the _submenutree_menutree_view() function just for testing, then all sub menu trees get rendered before the body.

What remains unexplained is why in some nodes the 'submenutree' content is being rendered before 'body', even thought both have 'weight = 0'.

flaviovs’s picture

Confirmed.

After alter table node_submenutree modify column submenutree_weight integer default 0 I'm now able to set weight < 0. Just setting weight to -1 makes the submenutree always appear before node body.

bengtan’s picture

Status: Active » Fixed

Hi guys,

Confirmed, tested, and committed.

Thanks for chasing this up and solving it for me.

Makes my job that much easier :)

There should be a new 6.x-1.4 release in a few minutes time with this fix.

(Note: This fix hasn't been backported to the 5.x branch. The 5.x branch is soooo old :)

Thank you.

flaviovs’s picture

bengtan, it would be good if you explain clearly on the documentation (and/or field description) that by default the node body has a weight of 0, so if one also set the menu parent/siblings weight to 0, then the results are unspecified.

Perhaps removing the 0 weight altogether is even a better solution -- if ones wants the menu after the body, one sets weight = 1, otherwise -1 is the correct choice.

bengtan’s picture

It's a little bit more tricky than that.

When submenutree was initially written (for Drupal 5.x), your observation was mostly true ie. the node body weight had a default weight of 0.

However, with Drupal 6.x, there is at least one commonly used module (CCK) which fiddles around with the body weight and can make it any value.

So, the idea of manually assigning a weight via a select dropdown in the submenutree fieldset is a bit outdated, naive and, depending on what other modules are also in use, somewhat broken now :(

The ideal fix would be to assign weights using some other mechanism .... An issue for another day, I guess, or when submenutree eventually moves to Drupal 7.x.

flaviovs’s picture

Hmmm... what if we position the submenu tree relatively to the body? Something like this (pseudo-code):


$body_weight = $node->content['body']['#weight'];

if ( $menu_position == 'before-body'  )
   $weight = $body_weight - 1;
else
   $weight = $body_weight + 1;

$node->content['submenu_tree']['#weight'] = $weight;

Status: Fixed » Closed (fixed)

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

ankycooper’s picture

Version: 6.x-1.3 » 6.x-1.4
Status: Closed (fixed) » Active

I'm using version 6.x-1-4, i display submenu in content which gets displayed below the body. now all of a sudden something happened, submenu has gone above the body in all the nodes. The weight setting does not make a difference, no matter what you set. i have tried upgrading it Dev version, uninstalling and reinstaling the module but no good
please look into it

ankycooper’s picture

Priority: Normal » Critical
bengtan’s picture

Hi,

> now all of a sudden something happened,

I think it would be helpful if you worked out what happened here.

The output of submenutree can be overridden by things like node templating or CCK, so it's possible something like that on your site is interfering or behaving unexpectedly.

ankycooper’s picture

i have CCK... so Does that mean submenutree is incompatibe with CCK. Please see wht can be done

bengtan’s picture

CCK isn't incompatible with Submenutree directly, but sometimes they may interact in funny ways regarding the weight.

CCK allows you to change the weight of some node fields (ie. visit .../admin/content/node-type/story/fields on your site).

For example, if your node's submenutree weight is 0 but CCK changes the weight of the CCK fields to -50 or so, then they will all appear before submenutree when you view the node.

You might want to see if this is actually the case for your site.

As for making any changes to make the two modules interact better, I'm a bit reluctant because I'm fairly busy, but we'll see.

bengtan’s picture

Priority: Critical » Normal
Status: Active » Fixed

Reverting this issue back to the status during comments #7 to #10. Not sure if the later issues are still applicable or not.

Status: Fixed » Closed (fixed)
Issue tags: -weight

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

brisath’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Issue summary: View changes
Status: Closed (fixed) » Active

I'm having a similar (same) problem with weight set to 10 but it is still showing in the middle of my content on a node instead of at the bottom. I have CCK installed. I was getting this on 6.x-1.6 also.

brisath’s picture

I found a work around for my case, by putting the file upload field down near the bottom in the order of content fields at admin/content/types/[nodetype]/fields

I was tipped off to this at https://drupal.org/comment/1384904#comment-1384904

ivnish’s picture

Status: Active » Closed (outdated)