see: http://drupal.org/node/160168#comment-311460
recopied here:
submitted by markus-v-drupal on September 26, 2007 - 19:22
Hi.
if you set "source for secondary links = primary links" and activate the "secondary links box" you get an empty box because links from the menu called "secondary-links" are shown.I changed the following in function menu_block($op, $delta) to get it working:
else if ($op == 'view') { $data['subject'] = check_plain($menus[$delta]); if ($delta == 'secondary-links' && variable_get('menu_secondary_links_source', 'secondary-links') == 'primary-links') { $tree = menu_tree_page_data('primary-links'); foreach ($tree as $link_data) { if ($link_data['link']['in_active_trail']) { $data['content'] = menu_tree_output($link_data['below']); break; } } } else { $data['content'] = menu_tree($delta); } return $data; }hope this is the right place. i'm not sure if it is the right way to do....
So the issue is basically a confusion between the "Secondary links" menu, and the "secondary links" as displayed (for example) at the top of the page below the primary links. I agree this could be confusing, but I don't think the above code is the correct approach.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | menu.module.patch | 920 bytes | JamieR |
| #9 | menu.module.patch | 852 bytes | kipkoan |
Comments
Comment #1
wwmv commentedI'm not sure you understand me correct, so i will try to explain it in in more detail.
First of a you can activate a block for every menu which will display to contens of this menu, right?
The "Secondary links" menu however is special because you can choose the source of the items.
The problem about all this is the disability of the Menu2Block Code to distinguish the source of the Secondary links menu. This means you get an empty Block if your "Secondary links Source" is "Primary links".
OK, i can see now why you describe this as "confusion between ..." :-/
However i think it is logical to assume that the a "secondary links block" is displaying the secondary links whatever the the source may be. But i also agree that this code is not the correct approach. I will think about it and hopefully get a working .patch file.
Comment #2
pwolanin commentedI think the best approach would be to correct the help text- I think the code is correct.
Comment #3
floretan commentedThere is indeed a problem with the two different meanings of "secondary links" (and it doesn't seem to be new in drupal 6). I tried to think of a different name that would best describe the second case, but the problem is that if we change that name we will also need to modify the php code to reflect those changes (no functional changes, but renaming variables and functions). If we only change the help text, the only result will be that the developers will be confused instead of the users...
Comment #4
wwmv commentedIn Drupal links are created from items in the corresponding menu e.g. the "Primary Links" are generated from the items in the "Primary Links" menu. Right?
So are the "Secondary Links". The only difference is that there are two diffrent sources for the items. imho...
So, i propose to make the following changes (on
admin/build/menu/settings):"Source for the secondary links:" -> "Source for the Secondary links menu items:"
"Secondary links" -> "Secondary links menu"
"Primary links" -> "Primary links menu"
and the helptext of course. (there is a typo anyway (choosen)) maybe like
... -> "If 'Primary links menu' is chosen the children of the active Primary links menu item (if any) will be shown instead of the links in the Secondary links menu."
I think this will do it without the need to rename any code, but YOU know the code better than me and I don't want to argue with you about that.
But i still think that from a user point of view secondary links are secondary links whoever the source is and therefore they should always appear in the Secondary links block. I mean this block is useless if 'Primary links menu' is the source ...
Sorry for the trouble and my pore English but I expected a different behaviour from Drupal.
Comment #5
wim leersComment #7
MestariM commentedIs there any updates on whether this is going to be fixed? It's just illogical, even if it wouldn't be a bug as such, but just a lack of feature.
I can't count on the template hardcoding, since I want to control on which pages the secondary links are to be shown...
Comment #8
doughold commentedYeah, any news on this. I am trying to use the secondary links block to show the second level of the primary links menu...
Comment #9
kipkoan commentedI tweaked the above code slightly allowing the primary & secondary links to use menus other than just "primary links". Patch file attached. Tested with Drupal 6.
[edit] -- bug fix in patch: do not try to display secondary menus if there are none -- causes a php warning if you do
Comment #10
Paul Natsuo Kishimoto commentedSubscribing.
@KipBond: I am marking this "patch (code needs review)" but I can't assign the feature request to you. If you want to update to take it, please do, as it's your patch.
I will try to test and review shortly.
Comment #11
Paul Natsuo Kishimoto commentedComment #12
Paul Natsuo Kishimoto commentedKipBond, I can confirm your patch of #9 works, but I don't think it is done according to the patch guidelines: http://drupal.org/patch/create
Can you reroll as it says there?
Comment #13
JamieR commentedIt's working for me as well. Here is a new patch file against drupal-6.10. Thanks!
Comment #14
doughold commentedAwesome, this patch worked great for me on 6.10. Will it be committed to the core so we don't have to re-apply it upon an upgrade?
Comment #15
pwolanin commentedno, I don't think this is the right solution - we have a 1-to-1 relationship of blocks to menus.
Comment #16
doughold commentedAlso, is there any way that we can make the title of the block the same as the parent menu item instead of "Secondary links"? I feel like that would make more sense.
Comment #17
pwolanin commentedComment #18
doughold commentedSorry, didn't mean to change the status...pwolanin, if this is not the right way to do it, what would you recommend doing for a secondary links block that draws it's info from the primary links menu tree?
Comment #19
mattyoung commented.