0

I've spent a grand total of 8 hours trying to solve this problem. The form needs to be separate from the node edit form so I can't use the form_alter hook. It needs a separate submit button. It only needs to appear on admin screens ... I've tried overriding page.tpl.php (the one used by me admin theme, seven) with no luck. See the code below ... absolutely nothing happens. When I add html into the page.tpl.php file (located in my modules folder), the html does not appear.

/**
 * Implements hook_theme_registry_alter()
**/
function my_module_theme_registry_alter(&$theme_registry) {
  $mod_path = drupal_get_path('module', 'my_module');
  $theme_registry_copy = $theme_registry;       // munge on a copy
  _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'seven', $mod_path);
  $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
  $hooks = array('node');
  foreach ($hooks as $h) {
    _my_module_insert_after_first_element($theme_registry[$h]['theme paths'], $mod_path);
  }
}
/**
 * Helper function for re-ordering arrays (needed by theme_registry_alter)
*/
function _my_module_insert_after_first_element(&$a, $element) {
  if(is_array($a)) {
    $first_element = array_shift($a);
    array_unshift($a, $first_element, $element);
  }
}

Also, I realize I can create forms the drupal way with the form hook (and page call backs). I've had success creating forms and showing them on custom urls, but I can't seem to programatically add the forms on pages I want, such as the node edit pages. If I could figure out how to do that, it would be preferable to just adding an html form into the template folder.

  • The node edit page is a form, and HTML won't let you nest a form within a form...what are you trying to accomplish exactly? – Clive Jul 17 '14 at 16:03
  • Yeah, I would like to display it outside the form, technically below the form so the two forms are siblings. The reason why it needs to be a seperate form is because it is essentially notifying my module of an update to the page. I can't have the module be notified every time the page is updated (because tiny edits need to be ignored, so I couldn't use a hook for when the page updates) but I need to implement a way of manually notifying the module that edits are made. – CHRIS Jul 17 '14 at 16:04
0

It sounds like you want to let the author notify your module of significant changes to a node. Another approach you could take is to add a field to your node type, such as "field_change_notification" (boolean/checkbox) ... then look to check if the author selected the checkbox in hook_node_presave. You can even set it back to unchecked so they can again notify your module on the next update.

function HOOK_node_presave($node){
  if ($node->type == 'article'){
    if ($node->field_change_notification['und'][0]['value']){
      drupal_set_message('A change has been made...');
      $node->field_change_notification['und'][0]['value'] = 0;
    }  
  }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.