And it begins

So it seems Drupal is just as convoluted as any other CMS system. Between the endless function-following and various other non-standard (read: not a way I would do it, but probably more standard than my way) ways to configure variables, I have finally found a way to get that damned Home link on the primary links without setting a database entry.

It took me about 3 hours to filter through the structure of Drupal's core modules. I first went to the themes folder and found the location where Primary Links (About Us right now) is filled in. That led me to the theme() function. I then obviously went to theme.inc in the includes folder because it would make sense for the theme() function to be there. There I found a massive function that all hooks pass through, so now I was at a loss.

Half an hour later, I somehow found a $primary_links variable in that file and tried to modify it before returning to the theme() function somewhere in the call stack but it turned out to apply to every links list call, so that was no good. Filtering down more (and with some help from the function, grep -C 3 -r I finally found the function I needed to modify to just get the Primary Links list.

For future reference it is located at line 1214 of 2474 in the menu.inc (looking back, that makes sense now). Its in the menu_primary_links() function. (Who knew?).
The code was:

return menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'));

The code now looks like:
return array('homepage' => array('href'=>"/node", 'title'=>'Home')) + menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'));

Recent comments