Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
kumkum29 CreditAttribution: kumkum29 commentedSolution :
I choose a contextual filter with "Parent menu link id" + custom php code + code :
Comment #3
BrightBoldThanks @kumkum29, you're a lifesaver.
Comment #4
BrightBoldRats. 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.Comment #5
gabriel.achille CreditAttribution: gabriel.achille commentedchanged 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...
Comment #6
kruser CreditAttribution: kruser commentedTo modify the code in #1 to work with any level in the menu, I modified it to the following:
Comment #7
kumkum29 CreditAttribution: kumkum29 commentedComment #8
BrightBoldStill 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."
Comment #9
Marco van Bemmel CreditAttribution: Marco van Bemmel commentedHi 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!
Comment #10
BrightBoldThanks @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. :)
Comment #11
henrik23 CreditAttribution: henrik23 commented@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.