I want to create a menu structure where several menu entries point to the same node (for example, node/1). When I click the "a", "b" or "c" item I want to go to the node number 1 and see that branch of the menu expanded as shown in the next example.
*a ----------> node/1
*b --------> node/1
*c ------> node/1
*d --------> node/998
*e ----------> node/999Often it just works right, but sometimes I get the menu contracted. For expample, clicking "a" menu entry leads to the following result:
*a ----------> node/1
*e ----------> node/999
It is due the order the menu entries are inserted in the database. Table entries for the second example are shown in the next table:
+---------------+------+------+-----------+------------+-------+-----+-----+-----+----+----+----+----+----+----+
| menu_name | mlid | plid | link_path | link_title | depth | p1 | p2 | p3 | p4 | p5 | p6 | p7 | p8 | p9 |
+---------------+------+------+-----------+------------+-------+-----+-----+-----+----+----+----+----+----+----+
| primary-links | 399 | 0 | node/1 | Title a | 1 | 399 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| primary-links | 400 | 399 | node/1 | Title b | 2 | 399 | 400 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| primary-links | 401 | 400 | node/1 | Title c | 3 | 399 | 400 | 401 | 0 | 0 | 0 | 0 | 0 | 0 |
+---------------+------+------+-----------+------------+-------+-----+-----+-----+----+----+----+----+----+----+
When function "menu_tree_page_data" gets a menu entry for the current page just gets the first result. Reverse ordering the query by depth will return the deepest menu entry first and the menu will be rendered correctly.
The attached patch adds the ordering to the query.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | menu-306412-3.patch | 2.32 KB | plach |
| #3 | menu-306412-3-1.png | 15.71 KB | plach |
| #3 | menu-306412-3-2.png | 17.92 KB | plach |
| #3 | menu-306412-3-3.png | 15.09 KB | plach |
| menu_patch.patch | 1.3 KB | gorbeia |
Comments
Comment #1
plachThe patch works as advertised.
Comment #2
pwolanin commentedI agree it's a bug not to have some ORDER BY set, to resolve multiple links. It's not clear to be if either depth ASC or depth DESC is correct.
Also, all bugs must be fixed in HEAD first.
Comment #3
plach@pwolanin:
After thinking about this some more I ain't sure that selecting just one row is the way to go: consider the attached (pretty weird) use case in which the same node (node 2) is linked multiple times in two different subtrees: we need every parent to be selected. Hence we should use all the rows in the result set.
Edit: ignore the first attachment, it's a wrong image.
Comment #4
plachComment #5
kscheirer#3: menu-306412-3.patch queued for re-testing.
Comment #15
pameeela commentedClosing this as a duplicate in favour of #732370: Go as deep as possible when building the active trail.. This issue is older but the other one has much more recent activity.