Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

Code

Hide Local Task Menu Tabs in Drupal

Here is how you can hide certain local task menu tabs in Drupal by utilizing theme_menu_local_task. The example below demonstrates how to hide the 'View' tab on user account profile pages. This code goes in your theme's template.php file.

Retrieve a URL's HTML using CURL and Drupal's Cache

Need to get the HTML output from a URL and place it in Drupal's cache? Well then, you may do something like this:

Retrieve CCK Filefield Imagefield Default Image Path

Here is how to get a Drupal 6 CCK Filefield Imagefield default image path:

Hook into and Preprocess Drupal Messages

So after the line dancing party at the pole barn in Corn County last night, I needed to prevent/hide Drupal messages from being displayed to certain user roles under certain conditions. Luckily Betty Sue, from Corn City, told me about theme_status_messages().

After copying theme_status_messages() into my theme's template.php file and renaming the function to mytheme_status_messages, I was ready to rock.

JavaScript Date Time YYYY MM DD HH MM SS

Robot: "What time is it JavaScript, buddy? And when you answer, it better be in the format of 'YYYY-MM-DD HH:MM:SS' in 24 hour format with preceeding zeros on the month, day, hour, minute and second, or else!"

Me: "Relax big guy, just call this function, friend."

JavaScript Regular Expressions in Internet Explorer

So today Internet Explorer again decided to be totally awesome...

I have a simple javascript regular expression that extracts the Drupal 'page' variable from a link that was clicked:

<a href="/code?page=1" id="tf_example_link">next page</a>
$('a#tf_example_link').click(function () {
  var page = /[\?&]+page=([0-9]+)[\?&]?/($(this).attr('href'));
  alert(page); // alert output: 1
});

This works in all browsers, except....... drum roll.............. Internet Explorer! Surprised? Probably not.

Create and Apply a Patch to a Drupal Module

From a terminal...

Patching a Single File

Navigate to your module's directory that contains the changes you have made:

cd /var/www/my-website/sites/all/modules/custom/my_module

Create the patch file by running a diff on your OTHER module file and comparing it to your updated module file:

diff -ruN /var/www/my-OTHER-website/sites/all/modules/custom/my_module/my_module.module my_module.module > my_module.module.patch

Copy the patch file to the same directory as the file that needs to be patched:

Apply a Patch to a Drupal Module

So after rolling out a bunch of new changes to a website, which involved an update to the Date module, a bug was introduced that was not detected during testing.

Ubuntu Cheat Sheet

SSH TUNNEL

Example 1 - MYSQL Query Browser

# open up the local (L) port 4000 (this is just a random port, you can pick others) on localhost and
# tunnel it to port 3306 on 123.456.789.101, without an interactive terminal (-N)

ssh -L 4000:localhost:3306 123.456.789.101 -N

# then in 'mysql query browser' we are able to connect to localhost:4000 with the DB credentials
# required for 123.456.789.101 and it will make the connection to 123.456.789.101's sql server on port 3306

Use Internet Explorer 6, 7 and 8 in Ubuntu

Ubuntu 10.04...

Pages

Subscribe to RSS - Code