What's been on my mind

How Drupal's CCK already provides a safely formatted cck field for display

Submitted by charles on

Came across an interesting post when investigating some "n/a" text appearing in a CCK node field when not logged in. I was using the code echo content_format('field_description', $field_description[0]); to safely format and output the description field. Not sure exactly why it happens but it turns out that there's no need to actually do it that way as CCK already provides a safe string of that field for outputting to the browser that is already formatted accordingly.

Drupal path not available to anonymous users in view block

Submitted by charles on
I created a view in drupal with some argument handling code. This code loaded the node so as to get the value of the path alias. I then used this path alias as a taxonomy argument for the view: if ($type == 'block' && arg(0)=='node') { $node = node_load(arg(1)); $path = $node->path; $args = array(); $args[0] = ''; if (!empty($path)) { $args[0] = $path; } return $args; }

phpMyAdmin "Save as file" file name template

Submitted by charles on
When using phpMyadmin to backup a MySQL database, there is an option near the bottom to save as a file. When you use this option, you can make your life easier by using a file name template that automatically names the backup file for you. By default it is the database name, but I find it useful to put a timestamp on it as well. To do that, use the following in the file name template field: %Y%m%d%H%M%S-__DB__ This will save your files in the following format: 20070815152612-databasename.sql

Google reader shortcuts

Submitted by charles on
I was looking for a shortcut to share an item in google reader, and came across a good list of shortcuts here. Ones that I use regularly: Shift S : To share an item S : To star an item J : Selects Next Item in list K : Selects Previous Item in list Space : Page Down Shift Space : Page Up

Web application page hierarchy podcast and slides

Submitted by charles on
Listened to a great podcast on web page hierarchy, that gives insight into how to use hierarchy on a web page to increase usability, prioritise content, and to ultimately help attain whatever goals you've set for your website. He also presents a number of case studies, slides of which you will find in his presentation pdf. So much good stuff here, like how users actually read a webpage (we don't - we just scan), and what tools to use to create hierarchy (contrast).

Change TinyMCE background colour in drupal from grey to white

Submitted by charles on
Found that by default the background colour for tinymce textareas was grey with my newest drupal 5 installation. Found this node which shows which style to add to your stylesheet to change the background colour to white. Add the following to your theme's style.css: body.mceContentBody { background: #fff; color: #000; }

Funny, strange, weird borders in drupal template (in firefox and not ie)?

Submitted by charles on
Took me forever to figure out that this was due to a tbody style in system.css. This border only showed up in firefox and not in internet explorer. The system style is: tbody { border-top: 1px solid #ccc;} I added this to my theme stylesheet: tbody { border: none;} Not sure if I'm missing something here, but this worked for me.

How to get the path to your theme in your drupal template

Submitted by charles on
Instead of hard coding your theme path into your drupal theme templates, it's better to use some built in drupal functions or template variables:
  • Use the $directory variable which will be available in your .tpl.php files
  • Use the path_to_theme() function - this provides the same output as the $directory variable
  • Use the base_path() function which will give you the url to the root of your site.
I always use absolute references, for example:

Podcast on virtualisation

Submitted by charles on
Virtualisation is going to be big! Apart from the benefits for businesses in server consolidation, virtualisation also is promising for software developers in utilising virtual appliances: "preconfigured, pre-installed virtual machine that includes the operating system and the application, all encapsulated in a virtual machine so that people can take a virtual appliance and install it", with out installing the operating system, configuring the operating system and the application". Check out the podcast on IT Conversations.

Adobe Kuler for colour ideas and cool colour functions in Adobe Illustrator CS3

Submitted by charles on
If you are looking for design ideas for colour schemes, check out Kuler (http://kuler.adobe.com). This is a site set up by Adobe which allows users to post colour schemes, and there's some great stuff there. Also, if you're an Adobe Illustrator user, check out this video on illustrator cs3 - there's some pretty amazing stuff you can do with colours...