Drupal code

Letting primary links be active / highlighted when browsing sub paths by overriding theme_links() function in Drupal

I wanted to highlight the primary links when browsing the secondary links (or sub links of the primary links). After some googling I understood that I had to override the theme_link() function. The overriding basically looks if the first slash text is in the in the link url currently active in the loop. All this is dependent on URL aliases being activated. It then proceeds to add the active class to the anchor.

After I messed with the theme_link() function I placed it in the template.php page which now looks likes this

<?php

Search and replace for characters in the whole database for Drupal

<?php
# Define which characters you want changed (key) and what you want them changed to (value)
$charChangeArray = array(
'Ã¥'=>'å',
'Ã…'=>'Å',
'ö'=>'ö',
'Ö'=>'Ö',
'ä'=>'ä',
'Ä'=>'Ä',
'ç'=>'ç',
'é'=>'é',
'¿½'=>'è',
'â'=>'â',

A script for converting your MySQL database collation to utf8 and utf8_general_ci and table columns to uf8_bin in Drupal

I recently had to migrate a database from one server to another. The new server was MySQL 5.xxx and I got the chance to change the collation and character set of my database. Being of Swedish origin there's always a hassle with å,ä,ö letters.

Code for a simple form, for upploading images in Drupal

Trying to find some code to make it easy for people to upload their favorite picture together with their favorite memory anonymously, I patched together this from various sources. It lets you upload files, pictures in this case, to your choosen directory.

<?php

function render_form() {

// Form:
$form['new']['upload'] = array('#type' => 'file', '#title' => t('Upload image'), '#size' => 40);
$form['new']['attach'] = array('#type' => 'submit', '#value' => t('Upload'));
$form['#attributes']['enctype'] = 'multipart/form-data';

urchinTracker(); // -->