Pages

Saturday 6 June 2015

Get information about node types

node_type_get_names()
returns an array of names
Array ( 
    [article] => Article 
    [page] => Basic page 
) 
node_type_get_types() returns an array of objects
Array (
  [article] => stdClass Object
        (
            [type] => article
            [name] => Article
            [base] => node_content
            [module] => node
            [description] => Use articles for time-sensitive content like news, press releases or blog posts.
            [help] => 
            [has_title] => 1
            [title_label] => Title
            [custom] => 1
            [modified] => 1
            [locked] => 0
            [disabled] => 0
            [orig_type] => article
            [disabled_changed] => 
        )

    [page] => stdClass Object
        (
           ..
        )
    ) 

<?php
  $type = $node->type;
  $types = node_type_get_types();
  $name = $types[$type]->name; 
  $description = $types[$type]->description;   
?>
<?php
$name = node_type_get_name($node);
?>
Returns all field definitions.
$var = field_info_fields("node", "node_type");

Reads in fields that match an array of conditions.
$var = field_read_fields(array('type') => 'node_type');

No comments:

Post a Comment