When using the Node id argument and passing in the nid of the active node via a default argument, if the node isn't in a menu, the view just displays everything that is in a menu.
I'm filing this as a support request instead of a bug because I'm not sure if this is the intended behavior. It is arising in menu_node_views_arguments_nid.inc in query(). If there's no $pid, I don't think anything should be returned, but right now the code skips over adding any limiting WHERE clause. There's probably a better way to manage that than what's below, but it does the trick.
else {
$where = "1 = 0";
$this->query->add_where(0, $where);
}
The use case here is a block that displays all the menu items 1 level below the active node. If there's a better way to achieve that instead of the nid argument and default values, maybe this isn't needed.
Sorry for not attaching a proper patch at the moment. If this is determined to be a bug, I will.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | menu_node_views-node-id-arg-no-result-returns-all-d7-673866-5.patch | 1.13 KB | joglin |
| #3 | node-id-arg-no-result-returns-all-673866-d7.patch | 1.19 KB | joglin |
| #2 | node-id-arg-no-result-returns-all-673866-2.patch | 1007 bytes | rjmackay |
Comments
Comment #1
agentrickardThis is likely a bug / oversight.
You could also use the Menu Block module for this, I think.
Comment #2
rjmackay commentedI have similar issues. I'm not sure that it tries to display everything in a menu. Rather it tries to display all nodes.
Patch attached
Comment #3
joglin commentedD7: works for me!
Comment #4
agentrickard@joglin Patches need to be rolled from the module root directory, not your system root.
Comment #5
joglin commentedOk, Sorry. But if this filter in the future will be part of a relationship, this solution will break all Querry!
Right?
Comment #6
agentrickardI don't know.
Comment #7
joelpittetThis doesn't seem to apply to D7 from the patch in #5.