Per node type flag.


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

A form alter implementation to create variables to flag certain features per node type. E.g. Show foo on blogs only: example_blog == 1;


Copy this code and paste it in your HTML
  1. /**
  2.  * Implementation of form_alter
  3.  */
  4. function example_form_alter($form_id, &$form) {
  5. if (isset($form['type'])) {
  6. if ($form['type']['#value'] .'_node_settings' == $form_id) {
  7. $type = $form['type']['#value'];
  8. $form['example'] = array(
  9. '#title' => t(''),
  10. '#type' => 'fieldset',
  11. );
  12. $form['example']['example_'. $type] = array(
  13. '#title' => t('Type has XXX'),
  14. '#type' => 'checkbox',
  15. '#default_value' => variable_get('example_'. $type, 0),
  16. '#description' => t(''),
  17. );
  18. }
  19. }
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.