University of Oregon

Updating select lists in bulk – w/ jquery, drupal

So I wrote this script 1 year and 1/2 ago about bulk label operations (Drupal 7 CCK – Creating ‘Label Bulk Operations’). Well the updateLabels() function from that code came in handy today. I needed to update dozens of CCK formats from various defaults to editable. If you’ve used editable fields you know it can come in handy but if you have a lot of fields you’ll be in a carpel tunnel conundrum if you try to change then all. So I pulled up the updateLabels() function opened the Firebug console and set all the various defaults to editable. And then back again. (more…)

Concatenate fields in a Fillable form

Recently someone referenced an old blog post: use data from one field to populate other fields in an acrobat fill-in forms and asked me how to concatenate multiple field values into one.

So I put together a sample pdf.


Drush enable all inactive modules

I’ve been using make files a lot lately and when ever I’m ready to release an updated file I like to verify that all the project versions are up to date. To leverage Drupal’s update functionality each project needs to be enabled. So I typically generate a new site from the make file and enable all the projects with drush. The key to that is the combination of commands:
drush en `drush pm-list --status="disabled,not installed" --pipe`
Here I’m enabling a list of module; specifically drush’s list of disabled and not installed modules.
drush pm-list --status="disabled,not installed"
That code gets you part of the way there. The addition of this:
makes it a script-able list. Then when I surround that with back-ticks and feed it to
drush en `...`
I’m in business. (more…)

Drupal 6 – Contact Override custom module

Just created a quick and dirty custom module: Contact Override. I posted it on bitbucket:   Nothing too exciting, just an override to the D6 contact form. It appends the senders email into the body of the email.   We had noticed that while emails from the Drupal contact form contained the senders email in the reply field that email address was often lost when forwarding the message. Here’s the readme: (more…)

Reponsive design and the iPad viewport

I had been noticing that the iPad’s viewport in webkit browsers was odd but I couldn’t put my finger on it. So I opened Safari on the iPad and ran some JS in firebug lite; the result: 768×504 in landscape and 768×928 in portrait mode. Not what I expected at all. The code I ran in firebug lite was:
alert(jQuery(window).width() + 'x ' + jQuery(window).height());
(prepend javascript: for use in the URL bar) Bottom line: the viewport width is 768px in both portrait and landscape mode. That’s a little odd. (more…)

Working on a file in two git branches at one time

I have a file in two different branches of a project that is so drastically different (hundreds upon hundreds of changes) that merging was becoming unreasonable. I’ll call that file CONVOLUTED.module.
I wanted to go old-school and compare the files side by side. Cutting and pasting changes with regular commits so I could test the incremental changes as I manually merged the files.
I figured there are several options to do this.

git branch – auto setup rebase = always

I was revisiting Randy Fay’s Rebase Workflow post and went down the ‘rebase’ rabbit hole again. Each time I learn a little more. Probably because I understand a little more… This time I landed here: ‘Simpler Rebasing …’ and as a result I’ve updated my git config to rebase on pull: git config –global branch.autosetuprebase always Note: this use of rebase isn’t the history altering version, rather an adjustment to the order of operations when pulling from a remote repo. The goal being to lay your local changes on top of the remote code each time you pull. Here’s how it looks in my git config now:
  autosetuprebase = always #Ref: #alternatively use: git config --global branch.autosetuprebase always
We’ll see how it goes. I’ll add this to my public git_bash_files repository if I like it.

Clean up your curl – fixing relative links in scraped content

A few years ago I Added jQuery browser check for ODT and Skillport eLearning. This week I updated that functionality and noticed a relative link in some remote content I was scraping via cURL. The problem being that the relative link needed to be fully qualified. Here’s the old table that I cURL from the Skillport support site: Screen Shot of the old compatibility table Here’s the updated table: a view of the table pulled in from skillport The culprit is the “Click here to view Skillsoft’s Browser Support Statement” at the top of the table. “here” links to /44007.htm which isn’t helpful. (more…)

Re-wrap a modified JS function

The question came up recently about the possibility of modifying an existing javascript without duplicating it. Yesterday, I found out that it’s indeed possible. The key to the solutions is to re-wrap an existing function with it’s modifications in an ‘anonymous function.’
Here’s the scenario:
I have a page where I check for some required browser plugins before sending users on to our eLearning site; Adobe Flash, Reader and Java.
I also check for optimal OS / browser combinations.
So in this scenario I was leveraging available JS & jQuery functions as much as possible but in one particular case I need to accurately display the users browser but jQuery.brower treats all webkit browsers as Safari.
So instead of installing a new jQuery plug in or write a script to parse the user’s browser info I took advantage of a function in the Java detection script I pulled in. (more…)

Drupal 7 – resizing the content area based on publish date

I was asked to look at a site where the content created before Jan. 15th 2013 was crafted to display nicely in a 600px wide area. New content is being added with a much wider area and with some thought given to the possibility of a fluid width (potentially responsive). So while setting a fixed width isn’t ideal I came up with a proof of concept that demonstrated the possibility using jQuery to resize the content area on page load. The content in question has two key elements to identify for jQuery:
  1. The publish date:
    $('.field-name-field-publish-date .date-display-single')
  2. The content area:
Here’s a sample of the code that could re-format the older content based on the published date:
$('.field-name-field-publish-date .date-display-single').length
//if( (currentContentDate < narrowContentCutOffDate)) {
if ( ( new Date($('.field-name-field-publish-date .date-display-single').text()).getTime() < new Date('January 15, 2013').getTime() ) ) {
}//end if
Wrapped in a Drupal.behaviors function it could be added to the site in a js file like so, to run once on each page load: (more…)