You are here

function modalframe_example_node_edit_page in Modal Frame API 6

Same name and namespace in other branches
  1. 7 modules/modalframe_example/modalframe_example.module \modalframe_example_node_edit_page()

Menu callback; Node edit form example.

See also

modalframe_example_form_alter()

modalframe_example_form_submit()

1 string reference to 'modalframe_example_node_edit_page'
modalframe_example_menu in modules/modalframe_example/modalframe_example.module
Implementation of hook_menu().

File

modules/modalframe_example/modalframe_example.module, line 160
Example for the Modal Frame module.

Code

function modalframe_example_node_edit_page() {

  // Send the Modal Frame javascript for child windows to the page.
  modalframe_child_js();

  // Let's find the last created node the current user has edit access to.
  $nid = (int) db_result(db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n ORDER BY n.nid DESC'), 0, 1));
  $node = node_load($nid);
  if (!$node || !node_access('update', $node)) {
    drupal_set_message(t('Sorry, could not find any node that you are allowed to edit for this test.'), 'error');
    drupal_not_found();
    return;
  }

  // Record the flag that we use in hook_form_alter() to know which node
  // should we operate with. Note that this flag could be anything else
  // that you may need to trigger your hook_form_alter() logic.
  $GLOBALS['modalframe_example_node_edit_page_nid'] = $nid;
  $output = '<h2>' . t('This example allows you to edit the last created node in this site.') . '</h2>';

  // Render the node edit form itself.
  module_load_include('inc', 'node', 'node.pages');
  $output .= node_page_edit($node);
  return $output;
}