I'm developing a multilingual (English/Italian) Drupal site, with one section to be 'Language Neutral' - a bibliography which uses the Biblio module. The clients wish to use the import function of the Biblio module. Unfortunately I can't set 'Language Neutral' as the default language for biblio nodes so after being imported they all become English, and thus invisible to the Italian side of the website.

I'm hoping to solve this by using PHP code with a rule so that upon creation of Biblio nodes, the language (a non-CCK field) is immediately switched from 'en' in the database to neutral, or ' '.

I'm relatively new to PHP and coding with Drupal. I've tried constructing db_query code with hook_update and hook_insert but I honestly don't really know what I'm doing. After much searching without success I'm hoping to get some assistance with this seemlingly simple task of changing the value one node field for a batch of imported records.

Thanks in advance.

-Geoff

Comments

jastraat’s picture

Geoff,
One way to do this is to start by creating a rule that triggers 'after saving new content' like you mentioned. As a condition, check that the created content is of type 'biblio' (no PHP needed). If there are other conditions you know of - add those as well.

Then, (after making sure the PHP filter module is enabled), add a 'Execute custom PHP code' action to your new rule.

For the PHP code, verify that your 'created content' is represented by the $node variable. (I think it will be by default, and I'll be assuming that in the following example. Note - haven't tested this particular code, but I was doing something similar at one point.)

$node->language = '';
return array("node" => $node);

Then, create a final action 'Save a content' (make sure it happens after you set the language)

Let me know if that works!

gpiersol’s picture

Status: Active » Fixed

This worked perfectly! Thanks so much for your help. I knew it was probably something very basic.

Cheers,
Geoff

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.