Skip to content

show_menu_below_id doesn't work past a softroot node #1039

c4urself opened this Issue Oct 7, 2011 · 6 comments

5 participants

c4urself commented Oct 7, 2011

Any levels / nodes between the root node and a soft node work well with show_menu_below_id. However as soon as one puts an id on a softroot or a descendant node, show_menu_below_id doesn't work for me. I've just upgrade to 2.2 (to see if this was fixed) and it doesn't work. This means 2.1 2.2 do not work (for me).


I've added a monkeypatch to my own code to make it work for the time being, it's definitely a hack because show_menu_below_id may not work as expected for levels higher in the hierarchy than a softroot, as the SoftRootCutter modifier is not implemented.

menus/ line 153.

        from import SoftRootCutter
        if root_id and isinstance(inst, SoftRootCutter):
evildmp commented Oct 10, 2011

This appears to affect show_menu too. A show_menu that would otherwise display the children of a particular page stops doing so when that page is a soft_root.

@ojii ojii referenced this issue Oct 14, 2011

Fix 1039 #1056

ojii commented Oct 17, 2011

fixed in 04cca87

@ojii ojii closed this Oct 17, 2011
krawalli commented Dec 2, 2011

Almost the same problem (show_menu_below_id and softroots):

meta (id meta)
  -- page 1
  -- page 2 (Softroot)
       -- page 2 sub 1
       -- page 2 sub 2
  -- page 3

when on page 2 or below, show_menu_below_id "meta" nothing is shown.

From my point of view: i asked for a menu tree below a given/named id and in that situation, softroots should not interfere the result.

Whats happening in code?
when the nodes for the tree are collected. the "SoftrootCutter" as modifier comes into game an will cut all nodes above a Softroot (seen from the current oage that it is requested from). So our named root_id is trimmed and does not be an element of the nodes variable. The further code does not find our named root_id and so nothing/empty is returned.

I'm for class SoftRootCutter(Modifier)
the code looks like this

\#only apply this modifier if we're pre-cut (since what we do is cut)
if post_cut or not settings.CMS_SOFTROOT                                           
    return nodes 

so add "or root_id" to the if statement to bail out of that modifier. when a root_id is given (show_menu_below_id do so)
# only apply this modifier if we're pre-cut (since what we do is cut)

if post_cut or not settings.CMS_SOFTROOT or root_id:
    return nodes 

I did not have any sideeffects b changing that statement (so far).

EDIT: Edited by ojii to display the tree and code nicer

@ojii ojii reopened this Dec 2, 2011
@evildmp evildmp was assigned Jun 16, 2012
@ojii ojii pushed a commit that closed this issue Jun 20, 2012
Jonas Obrist Fixes #1039
BACKWARDS INCOMPATIBLE CHANGES!!! Softroots only cut 'downwards' now,
not 'upwards'. According to @evildmp that's the expected behavior.
@c4urself who reported #1039 should confirm that this is actually what
is expected.

The fix itself was kinda simple because the 'downward' cuts were clearly
marked in the code.

I also added more extensive and better documented tests.
@ojii ojii closed this in bb7633f Jun 20, 2012

I found problem with this. Lets explain with example tree structure:

/home - ( id: home )
-- page in main tree 1
-- page in main tree 2
-- page in main tree 3
/top-menu - ( id: top_menu ) ( softroot )
-- page in top menu 1
-- page in top menu 2
-- page in top menu 2

In the template I have:
{% show_menu_below_id "top_menu" 0 1 1 1 "top_menu.html" %}
{% show_menu_below_id "home" 0 1 1 1 "menu.html" %}

When I'm in some of the main pages the "top_menu" is rendered, but when I'm in some of the pages in top menu the main menu is not rendered. I understand that when I am on page that is inside a softroot I can't see pages that is outside this softroot. For default menu this is Ok, but when I want pages bellow id I actually want theese pages.

I'm using the latest stable release (2.3.4)

ojii commented Nov 28, 2012

@vstoykov this seems to be a different issue, could you please open a new ticket for that? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.