Skip to main content

Node API

Alter field title of content type to display description below the field title

Submitted by system on
This can be achieved using hook_node_view <?php function ji_custom_node_view($node, $view_mode, $langcode) { if($view_mode != 'full'){ return; } switch ($node->type) { case 'blood_donor_form': foreach ($node->content as $field_name => $field_options) { if(isset($field_options['#title']) && isset($field_options[0]['markup'])) { $node->content["$field_name"]['#title'] = $field_options['#title'] ."".$field_options[0]['mark

Creating a Drupal 7 Node Programmatically

Submitted by amitsedai on
<?php
/**
* Basic Node Creation Example for Drupal 7
*
* This example:
* - Assumes a standard Drupal 7 installation
* - Does not verify that the field values are correct
*/
$body_text = 'This is the body text I want entered with the node.';

$node = new stdClass();
$node->type = 'article';
node_object_prepare($node); //Creates default settings for the node of a type
$node->title = 'Node Created Programmatically on ' . date('c');
$node->language = LANGUAGE_NONE; //String constant value for "und"

/* If u have body text do the following below