Drupal - Post Data via Ajax to PHP Menu Callback with JQuery and JSON

Drupal 7

I found this solid example for Drupal 7.

The code for D7 is much more elegant, there are some great new features in D7 to make this stuff easier.

Drupal 6

Put this PHP code inside your module, e.g. sites/all/modules/my_module/my_module.module

Drupal - Theme Table Example

Drupal 7

$header = array();
$header[] = array("data" => "Column Header Title 1");
$header[] = array("data" => "Column Header Title 2");

$row = array();
$row[] = "Row Column 1 Data"; 
$row[] = "Row Column 2 Data";

$rows = array();
$rows[] = $row;
$html = theme('table', array('header' => $header, 'rows' => $rows));

Drupal 6

Detecting Body Background Image Click with JQuery on a Drupal Zen Sub Theme

So the other day I needed to detect when someone clicks on the background image of my drupal zen sub theme. Here is how I did it using jquery:

Drupal Cron Run Failing and Timing Out

So I was trying to manually run cron.php on a drupal site, and it was timing out because the cron job couldn't finish. The cron job is quite intense, and I'm sure it isn't finishing because I am trying to run it during the day on a busy site. So in order to tell Drupal to forget about your last cron attempt:

  1. go into your drupal database
  2. go into the 'variable' table
  3. sort by the 'name' column ascending order
  4. look for any variable names beginning with 'cron_' and delete them

Here are some MySQL queries that should get the job done:

List of United States and Abbreviations in Various Code Forms


From abbreviation to name...

Create an Android Emulator SD Card and Write Data To It

Create the SD Card...

Let's create a 64MB sd card for our Android emulator, shall we?


From a terminal...

# cd ~/android-sdk-linux/tools
# ./mksdcard 64M ~/Desktop/sdcard.iso

Windows XP

From a DOS prompt...

cd C:\Program Files\android-sdk-windows\tools
mksdcard 64M c:\documents and settings\tyler\desktop\sdcard.iso

Now you can use the 'Eclipse Android SDK and AVD Manager' to create a new android virtual device that can use the path to the sd card you created.

JQuery Child Selector vs. Find

So today I thought I knew enough about JQuery to easily add a click function to some unordered list menu items in a Drupal Panel... wrong.

Since Panels adds a bunch of its own divs inside the container div, this was not working:

$('div.my_panel > > li').click(function () { alert('click'); } );

After a little experimenting, I realized the child selector doesn't work the way I thought. It is a "child" selector I guess, not a "grand child" selector. So instead I used the JQuery 'find' function.

This worked:

Load URL with Windows XP Scheduled Task

  1. Start -> Programs -> Accessories -> System Tools -> Scheduled Tasks
  2. Add Scheduled Task
  3. Select 'Internet Explorer' From The Application List
  4. Choose Your Preferred Interval Options
  5. Enter Your Username and Password (Username should appear by default)
  6. Check box next to 'Open advanced properties for this task when I click Finish.'
  7. Select the 'Task' Tab
  8. In the 'Run' field enter this e.g.: C:\PROGRA~1\INTERN~1\iexplore.exe

Drupal - Fatal error: Allowed memory size exhausted

Drupal can be a memory hog, it's very hungry. Occassionally you may run out of memory when trying to enable a module or some other feature. If this happens, you'll probably see a message similar to the following

Fatal error: Allowed memory size of # bytes exhausted (tried to allocate # bytes) in includes/

To fix this problem, I opened my sites/default/settings.php and added the following php ini setting:


Subscribe to RSS - Code