Skip to main content

drupal 7

Programmatically alter a Drupal menu without disabling access to the page.

I came across a need to keep a menu link active, but, I didn't want it to be displayed to the anonymous user. After much searching I found the hook_menu_link_alter() function and the hook_translated_menu_link_alter() function.

With these functions, I was able to alter the menu item that I wanted to not display with hook_menu_link_alter():


Drupal: Disabling another module's rule configuration from my own module.

Today I was working on a feature on a site that was using Ubercart's uc_roles module. By default, whenever a customer would buy a product with a role attached to it, an email would be generated stating what role that customer bought. However, in my use case, we did not want these emails generated and we needed to keep our settings in code.


Multi-dependent select elements in Drupal 7 using ajax

Recently I needed to modify a Drupal 7 node form to have two drop down select elements populate based upon a third select element's choice. I have altered select elements in the past to have a single dependency, but never have I made one element control the content of two different elements.

To start, I made the first element control the second (the old familiar way):

I need the selection in field_dropdown_1 to dictate what appears in the list for field_dropdown_2 and field_dropdown_3.


Migrating a Drupal 5 site to a Drupal 7 site.

I had to accomplish the task of migrating the content from a Drupal 5 site with 10,000+ nodes to a new Drupal 7 version. The caveat was that all of the node information needed to remain intact due to various links that were entered into the body of posts. My initial thought was to use a .csv file and import directly into the database. After some more research I discovered the migrate and migrate_d2d modules.


Theme_menu_links: How to target a specific menu in Drupal

Today we needed to override the menu links of one menu on our Drupal 7 site. We started with theme_menu_links(), but quickly decided that we didn't want to figure out what menu every menu link belonged to. After some searching we discovered this comment (https://api.drupal.org/comment/26939#comment-26939) which suggested using this naming structure:

THEMENAME_menu_link__MENU_NAME()


Getting a themed views title within a style tpl file

I ran into an issue today where I needed to get a themed views title from within a views row style template file (tpl). I tried using drupal_get_title() and menu_get_item() but the title elements were all blank for these. Next I inspected the $views object looking for the themed title but it was not listed. Finally, I discovered within $views->build_info the title and substitutions variables.