Category Archives: Snippet Library

The snippet library on WebDev, the Web Development blog, is a collection of useful bits of code. The snippet library contains PHP, JavaScript, CSS, XML, XHTML and ASP code.

When you output a Jump Menu from a View in Drupal 6, it displays & instead of the ampersand. Therefore ‘Terms & Conditions’ appears as ‘Terms & Conditions’ in the menu. The following bit of PHP code fixes this problem: … Continue reading

Posted in PHP, Snippet Library - PHP | Tagged , | Leave a comment

The PHP code snippet below shows how to add a GROUP BY clause to a Drupal 6 View. function hook_views_pre_execute(&$view) { switch($view->name) { case ‘Services2′: $search = array(‘ORDER BY’); $replace = array(‘GROUP BY node_data_field_parent_service.field_parent_service_nid ORDER BY’); $view->build_info['query'] = str_replace($search, $replace, … Continue reading

Posted in PHP, Snippet Library - PHP | Tagged , | Leave a comment

I recently had to add a member only section to a Drupal 7 web site. A problem I came across is that out of the box Drupal displays the User page after successful login and the member pages where not … Continue reading

Posted in PHP, Snippet Library - PHP | Tagged , | Leave a comment

If you have the Skype (www.skype.com) plug-in installed in Internet Explorer you may have noticed that it detects telephone numbers and converts them into Skype links so you can click it in order to make a call on Skype. If … Continue reading

Posted in Snippet Library - CSS | Tagged , , | 2 Comments

The following APS functions return true or false. Function isOdd(n) isOdd = cBool(n Mod 2) End Function Function isEven(n) isEven = (Not isOdd(n)) End Function

Posted in Snippet Library - ASP | Tagged , | Leave a comment

This PHP function takes a file size in bytes and return a human readable value in bytes, KB, MB or Gb. /** * function humanFileSize(integer $size) * * Receive the file size in bytes and return the human readable value … Continue reading

Posted in Snippet Library - PHP | Tagged , | Leave a comment

My Snippet Library is repository of code snippets for different web technologies. This collection is mostly to save me from re-writing the code again in the future, but visitors are free to use what they find here in there own … Continue reading

Posted in Snippet Library | Tagged | Leave a comment