Build menu using Menu_Block directly

I run across the need for some very specific menus built on the fly for Drupal once in a while. Things that really aren't blocks that should be running around the block admin. A great example would be ajax calls to obtain the submenus for an item and add them to the page post render for seo purposes.

If you need to access a very custom part of some menu, use the menu_block module, and tweak the following code to your needs:


Use TypeKit in a Drupal 7 Theme

One of the new themes we rigged up for a client requires the use of TypeKit. The easiest way I found to add the JS they provide is to just add it to the template.php file in hook_preprocess_page. The function drupal_add_js() will allow for external js files, as well as inline scripts. Use the code below, and if external js caching is turned on, it should pick that up while still providing the dynamic fire call you need. Just make sure you update the third parameter on the second function to be some region in your theme. The drupal semi default 'page_bottom' is a pretty safe call.


Alter views display options at the theme level

My client today need the mobile version of the retailer locator to shrink down and fit the new mobile theme. Going from about 700px wide to 300ish, with a height change as well. The cleanest route I found for doing this is to have the theme itself alter the view just before rendering. Here's the code, pretty simple once you get past all the dominating recursion.


Creating date popup fields using Drupal form api

Note that the date module is required for this form element type.
An additional guide to using these elements is available on
For a full list of options available, you'll need to check the module code itself at: date/date_api/



Subscribe to Fragmented Thought RSS