Skip to main content

Blog

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()


AWS - IAM Permissions - Setup permissions for one user to access only one S3 bucket

While using Amazon's AWS system, we needed to give access to one S3 bucket. Todo so, we ended up using Amazon's IAM. Once we created the user in the AWS system, we created the following policy to allow this new user to only be able to read/write to their bucket:


Drupal functions I can't live without anymore

Below is a list of Drupal functions that I can no longer live without, but for some reason I have trouble remembering them. So, here is a list of functions that I use regularly.

Drupal 7

drupal_clean_css_identifier - http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_cl…
Use this function to sanitize css identifiers.

Check back as I'll continue updating this list.


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.


Migrating Drupal 6 'sites/default/files' directory to 'sites/sitename.com/files'

Just wanted to post these instructions for my own sanity, and so I wouldn't lose them as I've used them numerous times over the past year. Thanks Jeff for the original post:

http://www.midwesternmac.com/blogs/geerlingguy/moving-your-drupal-files…


Add New Version of jQuery to Drupal 7 Theme

Today I needed to add the newest version of jQuery (1.7) to a custom Drupal 7 theme that I was building. I initially used the jQuery Update module and hacked the replaced version of jQuery with the version I needed. I know, this was not the best practice, but this was a rush job and I was in a hurry (don't hack the core, or any contributed modules for that matter!). Everything was working fine until I wanted to add a new field to a content type and the form quit working in the admin overlay, which was using the Seven theme. Crap!


Views menu tab displayed on only certain content types.

I recently ran into an issue where I wanted to use a views page as a tab for nodes of type 'course'. I added the view page like normal, providing my path of: node/%/course-list.

Next, I added my menu item entry as a 'menu tab'.

Perfect, except that the menu tab was displaying on every node when I needed it to only display on one node type.


Drush Scripts: Running Drush Commands from Inside a Drush Shell Script

We have a website that updates numerous nodes nightly with an uploaded XML file. This XML file is then processed with Drupal's batch api, and when the XML file is uploaded manually, the script works perfectly. However, in real life, this XML file is uploaded programmatically by a script running on another server. Programmatically, the file gets uploaded and the batch begins properly, but on the successive redirects, the batch fails. This is because, the pseudo browser window from our publishing script closes.


Drupal Calendar: Use a Drop Down Menu to Change Calendar Dates

We had a Drupal 7 site setup with a default calendar instance that was displaying content of type 'event'. Due to the limited number of events this site would promote, it was decided to change the navigation from the standard 'Next/Previous' to use drop down menus where the user could choose the month/year they wanted to view.

The original look


Drupal Book Permissions: Only Let Users Add Content to their Own Books

Today's project required me to fine tune Drupal's standard book module. Basically, I needed to limit the choices in the 'Book Outline' area to only display books that the user was the author of. Unfortunately, Drupal's default permissions don't allow for this. Either the user can administer all outlines or none, nothing in between.


Change Permissions for Roles in Open Atrium

Today I was working on an intranet site using Open Atrium. Our client wanted to post their employee handbook on the intranet using the atrium notebook module. The problem is that, by default, all authenticated users are able to post a handbook item. Obviously, this wouldn't work with an employee being able to modify the employee handbook online.


How to add a class to a Drupal 7 region

Today I needed to add a class to a Drupal 7 region and found the lovely template_preprocess_region() function to do the dirty work for me. With this function, you can easily add any class to your regions with the code below.

In a nutshell, you find the region you want to add the class to and then append your class onto the end of the classes_array variable.