I was already using this module when i realized that it would be nice if some menu items can automatically link to their first child (just like someone else described here: http://drupal.org/node/433616). So, I wrote a patch that does this: if you enter 'firstchild' as path, the menu item automatically links to the first child. I hope you find this a useful addition to your module. I'm looking forward to any reactions and reviews.

Comments

marcvangend’s picture

StatusFileSize
new2.4 KB

Oops, I left a php syntax error in my patch. Use this one.

tamerzg’s picture

Hi marcvangend ,

thank you for submitting the patch. We will review it and add it to next revision.

marcvangend’s picture

Status: Needs review » Needs work

I have found that my patch doesn't work correctly on a site with language prefixes.

Also, I noticed a new module (Menu Firstchild, http://drupal.org/project/menu_firstchild, first added less that 2 hours before I posted the patch above) which does the same thing, but in another way. I am not the only one who has noticed the kinship between Special Menu Items and Menu Firstchild; see http://drupal.org/node/515960. Maybe it should be considered if both modules can join forces?

tamerzg’s picture

Hi,

I have tested your module. It is really nice feature to have. However I noticed a bug. If firstchild is submenu, then it will still point to firstchild dummy page. I traced the code and it seems that it will never enter if statement:
if ($branch['link']['mlid'] == $link['mlid']) {
$firstchild = array_shift($branch['below']);
break;
}

Also I tried it with Jquery menu and in there didn't work at all. Hope we can fix this, and we will add it in new release.

And yes, I have seen Menu Firstchild module. If author is interested in joining forces, I will be glad to accept him and give him CVS access.

tamerzg’s picture

Oh yes, sometimes I got this error when saving firstchild item:

warning: array_shift() [function.array-shift]: The argument should be an array in C:\wamp\www\drupal611\sites\all\modules\special_menu_items\special_menu_items.module on line 114.

flaviovs’s picture

FYI: the Menu First Child module does exactly this.

gagarine’s picture

Version: 6.x-1.3 » 7.x-1.x-dev

I will commit this for D7 if someone provide a patch. Please take a look at the implementation of Menu First Child (because it works and was tested a lot).

gagarine’s picture

Status: Needs work » Closed (won't fix)

As say in 6 their is another module for that..