Get an array with the names fields of a determined type of content


/ Published in: PHP
Save to your folder(s)

This snippet saves in the $return array all the names of the fields that a content type has added with CCK, has to be installed the cck module.


Copy this code and paste it in your HTML
  1. $type_name = 'contacto'; #Content Type name
  2. $type = content_types($type_name); #Get all the info of the type
  3.  
  4. if ($type) {
  5.  
  6. $return = array();
  7.  
  8. foreach ($type['fields'] as $field_name => $field) {
  9.  
  10. $return[] = $field['field_name'];
  11. }
  12.  
  13. $return = implode("\n", $return);
  14. } else {
  15.  
  16. $return = FALSE;
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.