Hello,

In view, is it possible to get the other nodes of the same parent?
If I use the filters contextual "menu: node-id" I get the nodes childs of the current page, but not the nodes at the same level and the same parent.

Thank you for your help.

Comments

kumkum29’s picture

Status: Active » Fixed

Solution :

I choose a contextual filter with "Parent menu link id" + custom php code + code :

$menu_item = menu_get_active_trail();
$menu_item_plid = $menu_item[4]['plid'];
return $menu_item_plid;

Status: Fixed » Closed (fixed)

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

BrightBold’s picture

Thanks @kumkum29, you're a lifesaver.

BrightBold’s picture

Rats. Spoke too soon. It worked in the view preview but on the page I get Notice: Undefined offset: 4 in eval() (line 2 of /sites/all/modules/contrib/views/plugins/views_plugin_argument_default_php.inc(53) : eval()'d code). I was trying this because something broke my level 4+ Menu Blocks, and I think whatever that was is breaking this too.

gabriel.achille’s picture

Status: Closed (fixed) » Needs work

changed the status because this is not fixed for the module.
There is currently no predefined view relationship in the module to handle this particular situation.
Anyone interested if i'm working on that ? (adding relationship "Menu: Sibling menu" or "Menu: Children menu" similar to "Parent menu link id"...)

The other way seems to do something similar to #1...

kruser’s picture

To modify the code in #1 to work with any level in the menu, I modified it to the following:

$menu_item = menu_get_active_trail();
$current_item = array_pop($menu_item);
$menu_item_plid = $current_item['plid'];
return $menu_item_plid;
kumkum29’s picture

Issue summary: View changes
Status: Needs work » Fixed
BrightBold’s picture

Status: Fixed » Active

Still not the correct status. It's not fixed for the module, so it shouldn't be "fixed," and there's no patch supplied so it shouldn't be "needs work."

Marco van Bemmel’s picture

Hi BrightBold,

I tried
- contextual filter with 'Parent menu link id',
- select 'Provide default value'
- than select 'custom php code'
- enter code of #6

After this i entered a new contextual filter:
- contextual filter 'Menu: depth'
- select 'Provide default value'
- than select 'Fixed value'
- enter the level (in my case 3)

If needed you can add a third contextual filter to exclude the current NID.

Hopefully this will help. It works very well with my situation.

Good luck!

BrightBold’s picture

Thanks @TDDF. If I can remember which site I was working on two years ago that was having this problem, I will give your solution a try. :)

henrik23’s picture

@BrightBold: Superb, it works! Find your old project and use this solution!
@Marco van Bemmel, @kruser and @kumkum29: Thank you for your work. Using this solution I can now list all the sibling nodes like I wanted to do for two years but could not manage without this clou.