Archive for March, 2008

Netgear WG111 on Debian Lenny with ndiswrapper

Tested on: Debian Etch, Lenny/Sid (Testing), kernel 2.6

  1. Plug WG111 and type lsusb to verify hardware is plugged. You should get something like:
    Bus 003 Device 002: ID 0000:0000 NetGear, Inc. WG111 WiFi (v2)
    Bus 003 Device 001: ID 0000:0000
    Bus 001 Device 001: ID 0000:0000
    Bus 002 Device 001: ID 0000:0000
  2. On root shell, type:
    m-a prepare
    m-a a-i ndiswrapper
    modprobe ndiswrapper

    Now ndiswrapper module is loaded. (if you got a FATAL: Module ndiswrapper not found fatal error, repeat these steps)
  3. If interface is successfully modprobed, then type
    update-modules
    To create ndiswrapper module config files.
  4. Add
    ndiswrapper
    to /etc/modules to load this module on boot.

  5. apt-get install module-assistant wlassistant ndisgtk ndiswrapper-utils
    Install some utilities to configure wireless interface.
  6. Run ndisgtk (or type ndiswrapper -i /media/cdrom0/ndis5/netwg111.inf, where cdrom0 is Netgear driver disc)
  7. Select Netgear driver from CD-ROM (netwg111.inf): it’ll be copied automatically to /etc/ndiswrapper
  8. Copy other files under /media/cdrom0/ndis5 in /etc/ndiswrapper/netwg111/
  9. If interface is not detected, type ndiswrapper -m to write modprobe config files for it.
  10. Use gksu network-admin or gksu wlassistant to configure your wireless connection.

Tip: If after system upgrading you cannot access to wireless network, repeat step (2).

See also:

Translate Drupal block titles

A simple snippet based on theme_block() and t() functions. (Tested on Drupal 5.x, Zen subtheme).

  1. Copy and paste this code into your template.php:

    function zen_block($block) {
    $output = “<div class=\”block block-$block->module\” id=\”block-$block->module-$block->delta\”>\n”;
    $output .= ” <h2 class=\”title\”>”.t($block->subject).”</h2>\n”;
    $output .= ” <div class=\”content\”>$block->content</div>\n”;
    $output .= “</div>\n”;
    return $output;
    }

  2. Go to admin/settings/locale/string/search and search the title to translate from English to your localization language.

Add CSS class to drupal form fieldset

Tested on:

  • Drupal 5.x
  • Zen custom subtheme

Customizing Drupal form appearance may sound difficult. But to add a CSS class is (surprisingly!) simple using theme_fieldset themeable function.

  • Copy theme_fieldset code from Drupal manual page
  • Paste to your template.php:
    • If you’re using a Zen theme, change theme_fieldset to zen_fieldset. You can try to use this method with your theme prefix.
    • If you’re using a theme based on phptemplate engine, you can change theme_fieldset to zen_fieldset to have the same effect of above (try one of this, not both).
  • Change the resultant code as you wish.

I’ve attached an example to generate CSS class from fieldset title: Add CSS class to drupal form fieldset.

# custom fieldset CSS class from element #title
$css_class = “my-custom-class-”;
$css_class .= str_replace(” “,”-”,strtolower($element['#title']));
# using transliteration module to transliterate/strip non-ASCII character where available
if(module_exists(’transliteration’)){
# including Transliteration functions
require_once(drupal_get_path(’module’, ‘transliteration’) .’/transliteration.inc’);
$css_class = transliteration_clean_filename($css_class);
}

Adding this code to your template:

  • Take all Drupal generated fieldset title
    • e.g. “Impostazioni del menù”
  • Transform it in a CSS class using Transliteration module
    • e.g. “my-custom-class-impostazioni-del-menu”
  • Queue it with other CSS classes (where available)
    • e.g “collapsible my-custom-class-impostazioni-del-menu”

I apply a previous substitution of whitespace using “-” (transliteration module use underscore “_”) and you can do the same, but later remember to use transliteration_clean_filename to safely sanitize class name for any other case you’ve not contemplated (accents, special characters).