Drupal 7 – Programatically setting Link field value

The method for Programmatically setting a link field value (see the Link module) in drupal 7 is slightly different from how it was set it in drupal 6. Here is some code for creating a new node and setting its link field (called field_url):


$node = new stdClass();
$node->type = 'website';

$node->title = $site_name;
$node->language = LANGUAGE_NONE;

$node->field_url[$node->language][0]['title'] = "www.ridgesolutions.ie";
$node->field_url[$node->language][0]['url'] = "www.ridgesolutions.ie";


0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *