Hi there,

Im having problems with InsertNode and my breadcrumbs, and I'm pretty sure the problem is generated in InsertNode.

I have approximately this layout for my books Contact and About :
Contact
--Employees
--Contact form

About
--Employees
--Some other about

Now, I want both Employees pages to be the same, so I used InsertNode with the following tag in the about/employees node [node:contact/employees body] since I only want to embed the body. This does work fine, however it also overrides the breadcrumb, which should be Home>About>Employees, but now is Home>Contact>Employees>Employees. This is not the case when I use no parameters or themed, but both show the title, which I don't want.

I reckon the change of the breadcrumb happens through the node_view call, but I do wonder if it's necessary to call node_view for this?

Greetings,
Jeff

Comments

AlexisWilke’s picture

Hi Jeff,

Yeah. I have noticed the problem.

I will apply a fix. I just have to read the current crumbs on entry and restore them on exit. This is a problem in many cases, not just books.

Thank you for reporting the problem.
Alexis Wilke

AlexisWilke’s picture

Okay, I went ahead and added the calls in the -dev version. It should be available within 12 hours.

Thank you.
Alexis Wilke

Anonymous’s picture

So, I finally got to test the dev version. It's working better now, but not 100% correct yet.

With the books I had in the former example, the breadcrumb I expect to find is still:
Home>About>Employees
It gave me
Home>Contact>Employees>Employees
before updating to the dev version, it now gives me:
Home>Employees

Yet still, thanks for your quick response!

Jeff

AlexisWilke’s picture

Without the [node:123] tag, what do you get as the breadcrumb?

Thank you.
Alexis

Anonymous’s picture

Home>About>Employees (exactly as should be).

I would like to add that I seem to have this when using the body or content parameter.
When using no parameters I don't have the problem, but I also don't get anything from the original node inserted (I should get the same result as from using the content parameter).
Even better: using the themed parameter does correctly preserve my breadcrumb (but I don't want to use the themed parameter, because I don't want to insert the title)

AlexisWilke’s picture

Okay... How about this one? New -dev within the next 12 hours...

Thank you.
Alexis Wilke

Anonymous’s picture

I'm now getting the same as I had when I originally opened this thread.

AlexisWilke’s picture

Assigned: Unassigned » AlexisWilke

Jeff,

Just thinking that the theme() calls could have a side effect on the breadcrumb since it computes it somewhere somehow... and it could very well be in there. So I now save the breadcrumb before calling the processing function and restoring right after.

Let me know how this one behaves.

Thank you.
Alexis Wilke

Anonymous’s picture

I did a quick test here, I tested 3 different parameters: themed, body and content, with body being the parameter I'd want to use.
In the former dev version these were the results:
themed: breadcrumb working as expected
content: breadcrumb behaving as in the first post in this issue
body: same as content

In this version:
themed: breadcrumb behaves as it should
content: breadcrumb behaves as it should
body: breadcrumb behaves as in the first post of this issue.

I don't have much time to look into a fix for this myself, but I might use some spare home (non-paid) time to do it later this week.

Jeff

AlexisWilke’s picture

Jeff,

I don't have that much time either... and this is a free module too. 8-)

At this point, I'm not too sure what happens, but I guess that body will at some point generate a call to drupal_get_breadcrumb() which then puts some default breadcrumb.

Maybe the following would work for you (InsertNode.module line 40+):

      $breadcrumb = drupal_set_breadcrumb();
      drupal_set_breadcrumb(array('ignore'));
      $text = preg_replace_callback('/\[node:([^\s\]]+)((?:\s+[a-zA-Z]+(?:=[^;]*;)?)*)\s*\]/', '_InsertNode_replacer', $text);
      drupal_set_breadcrumb($breadcrumb);

It prevents the call to the menu_get_active_breadcrumb() function which I think is the one causing the problem (i.e. it must have some static/global variable).

Thank you.
Alexis

Anonymous’s picture

Actually, this shows the following:

ignore > Employees

I've done a dirty var_dump($breadcrumb) directly after getting it with drupal_set_breadcrumb(), it showed me NULL. This shows me that it is the call drupal_set_breadcrumb($breadcrumb) doesn't do anything at all.

It seems to me that the filter on the node is being called before an active breadcrumb is set when processing the node, and that when doing so it recognizes a breadcrumb is already set and tries to alter it somehow. I'm unsure wether that is/seems solvable.

Note that I turned on the option to show the current page's name in the crumb in my theme settings.

Jeff

AlexisWilke’s picture

Jeff,

Good point. We cannot reset the breadcrumb to nothing!

So what we'd need to have happen is a call to the breadcrumb from the book node before our filter gets called. Hmmm... Maybe we can call that explicitly somehow.

Thank you.
Alexis Wilke

Anonymous’s picture

I've been having a brief look and some other testing. When (on the same page!) I insert a node that does not have it's breadcrumb set by another module, I don't seem to have this problem. (although I have only tested it with taxonomy breadcrumb and the breadcrumbs set by book, which is (I think) done by setting the active menu trail), I don't have the time to dig any deeper at this moment, but I thought maybe it helps you.

Jeff

AlexisWilke’s picture

The problem is line 1810 in include/theme.inc which wants the breadcrumb to generate the node.

This type of a problem may happen in different location throughout Drupal.

...
$variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb());
...

I guess that one solution would be to fix the breadcrumb with the default value after we return from the call. It may work in your case... The idea of the menu_get_active_breadcrumb() is to use what is called menu_get_item() and the book hierarchy is form with the use of a menu. That's the menu we'd need to make use of when menu_get_active_breadcrumb() is called and I'm afraid that is not the case from within the InsertNode module... (afterall, we had a drupal_get_breadcrumb() called first for a while.)

If you want to try, do this right after line 41 (after the preg_replace_callback() function call):

  $text = preg_replace_callback(...);
  drupal_set_breadcrumb(menu_get_active_breadcrumb());

That would reset whatever happens in the sub-node to what would otherwise be expected...

Let me know whether that fixes the problem.

Thank you.
Alexis Wilke