Wordpress - Custom Body Classes

Add custom classes to the <body> tag in Wordpress.  Classes added:

-Not front page
-Post type
-Post slug
-Post slug ancestors
-User logged in
-User is admin
-ACF block class depending on block type

Make Field Collection Fields Translatable in Drupal 7

On the Cornell AAP website, many nodes use field collections, and recently had to make some content types translatable.  Field collections are not translatable by default - there is a patch that needs to be applied.  I'm going to write about how to do this so you don't have to waste a good part of your day figuring it out.  

At the time this post was written the module and Drupal versions used are:

Foundation 5 and IMCE

Having trouble getting IMCE to play well with Foundation 5?

Why does IMCE not work with Foundation 5?

  • Foundation needs jQuery 1.10 or higher
  • IMCE uses $.browser which is not in 1.10
  • IMCE needs to use another jQuery version or use the jQuery migrate js file which is outlined below. 

Work around:

Saving Twitter Tweets to Nodes in Drupal 7 with hook_cron

On Cornell AAP's new site (http://aap.cornell.edu) one of the requirements was to show their Twitter tweets in different pages.  The tweets had to match the look and feel of the new site, and had to pull in new tweets periodically so I knew I had to use hook_cron. Tweets that have images also needed to be saved and clicking the Tweet's image takes the user the original image.

Template file location in Drupal 7's hook_theme when template and path are set

This is a brief guide of where Drupal 7 will look for the template.tpl.php file in a hook_theme item depending on the 'template' and 'path' settings, or lack of.  For a thorough and complete explanation head to the official hook_theme page.

Our setup:

Module: modules/mymodule
Theme: themes/mytheme

We're going to output the value using $html = theme('news_filters').

Configuration 1:

Homemade Mosquito Trap

Items needed:
1 cup of water
1/4 cup of brown sugar
1 gram of yeast
1 2-liter bottle

How:

Refresh Firefox With a Keyboard Shortcut in Coda

While in Coda, I press Command + R to refresh Firefox, saving one (measly) click.  There are probably better ways to do this like using the LiveReload plugin. 

First, create the Service in Automator:

Merge Multiple PDF's in PHP using shell_exec()

I had a bunch of PDF's that needed to be merged into one PDF file and present it as a file download to the user.  To do this I first installed Pdftk (the pdf tookit) on the server then ran the command via shell_exec().  Steps with code below.

Show Total Number of Disqus Comments of a Page in Drupal 7

On a recent project I had to show the total number of comments posted using Disqus for each node on a page. What the page did was loop through a bunch of nodes and render the teaser view of each node.  The teaser was shown by rendering node.tpl.php, and in that file I had to display the total number of comments. Clicking a teaser view took me to the full page of the node that also contained the Disqus commenting box.

To do this I had to do add code in two places:

Load a Different Theme on Mobile Devices in Drupal 7

I recently finished a project and soon after the customer asked that the site load a different theme if the visitor was on a mobile device such as an iPhone or Android phone. The site is in Drupal 7 and the mobile version needed to load the same content as the main site. I came up with these requirements: