Hi,

I want to create a 'field' in which the field should display the 'node types' available in DB.
Is there any option to display 'node types' (Content Types names), as select list options for a field.

Thanks in Advance

Comments

mansigajjar’s picture

Hello,

please find below code:


//an array of node types, as objects
$types = node_type_get_types();

// define array
$node_type = array();
  
//Iterate through node type and prepare key value array
foreach ($types as $val) {
    $node_type[$val->type] = $val->name;
}

Now print $node_type array which display all the node type.

Annanna’s picture

Thanks for your reply...

I am searching for something that can be done without touching the code. Some modules similar to Entity Reference.