InsertNode and breadcrumbs
| Project: | InsertNode |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | AlexisWilke |
| Status: | active |
Jump to:
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

#1
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
#2
Okay, I went ahead and added the calls in the -dev version. It should be available within 12 hours.
Thank you.
Alexis Wilke
#3
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
#4
Without the [node:123] tag, what do you get as the breadcrumb?
Thank you.
Alexis
#5
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)
#6
Okay... How about this one? New -dev within the next 12 hours...
Thank you.
Alexis Wilke
#7
I'm now getting the same as I had when I originally opened this thread.
#8
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
#9
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
#10
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+):
<?php$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
#11
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
#12
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