Skip to main content
Notice removed Draw attention by CommunityBot
Bounty Ended with no winning answer by CommunityBot
Rollback to Revision 2
Source Link
Yuseferi
  • 22.2k
  • 22
  • 118
  • 218

I try this but not work for me,

function mymodule_menu() {
  $items = array();
 
  $items['mymodule/page'] = array(
    'page callback' => 'mymodule_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  $items['mymodule/%ctools_js'] = array(
    'page callback' => 'mymodule_callback',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  return $items;
}


/**
 * Helper function to make a link.
 */
function _mymodule_make_link($link_text = '') {
  // Set a default value if no text in supplied.
  if (empty($link_text)) {
    $link_text = 'Magical Modal';
  }
 
  return '<div id="magical-modal-link">' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . '</div>';
}



/**
 * An example page.
 */
function mymodule_page() {
  // Load the modal library and add the modal javascript.
  ctools_include('modal');
  ctools_modal_add_js();
  return _mymodule_make_link('Magical modal');
}



/**
 * Ajax menu callback.
 */
function mymodule_callback($ajax) {
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');
 
    $form_state = array(
      'ajax' => TRUE,
      'title' => t('MyModule Modal Form'),
    );
 
    // Use ctools to generate ajax instructions for the browser to create
    // a form in a modal popup.
    $output = ctools_modal_form_wrapper('mymodule_form', $form_state);
 
    // If the form has been submitted, there may be additional instructions
    // such as dismissing the modal popup.
    if (!empty($form_state['ajax_commands'])) {
      $output = $form_state['ajax_commands'];
    }
 
    // Return the ajax instructions to the browser via ajax_render().
    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('mymodule_form');
  }
}



/**
 * Drupal form to be put in a modal.
 */
function mymodule_form(&$form, $form_state) {
  module_load_include('inc', 'node', 'node.pages');
$form = node_add('article');
  return $form;
}

I try this but not work for me,

function mymodule_menu() {
  $items = array();
 
  $items['mymodule/page'] = array(
    'page callback' => 'mymodule_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  $items['mymodule/%ctools_js'] = array(
    'page callback' => 'mymodule_callback',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  return $items;
}


/**
 * Helper function to make a link.
 */
function _mymodule_make_link($link_text = '') {
  // Set a default value if no text in supplied.
  if (empty($link_text)) {
    $link_text = 'Magical Modal';
  }
 
  return '<div id="magical-modal-link">' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . '</div>';
}



/**
 * An example page.
 */
function mymodule_page() {
  // Load the modal library and add the modal javascript.
  ctools_include('modal');
  ctools_modal_add_js();
  return _mymodule_make_link('Magical modal');
}



/**
 * Ajax menu callback.
 */
function mymodule_callback($ajax) {
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');
 
    $form_state = array(
      'ajax' => TRUE,
      'title' => t('MyModule Modal Form'),
    );
 
    // Use ctools to generate ajax instructions for the browser to create
    // a form in a modal popup.
    $output = ctools_modal_form_wrapper('mymodule_form', $form_state);
 
    // If the form has been submitted, there may be additional instructions
    // such as dismissing the modal popup.
    if (!empty($form_state['ajax_commands'])) {
      $output = $form_state['ajax_commands'];
    }
 
    // Return the ajax instructions to the browser via ajax_render().
    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('mymodule_form');
  }
}



/**
 * Drupal form to be put in a modal.
 */
function mymodule_form(&$form, $form_state) {
  module_load_include('inc', 'node', 'node.pages');
$form = node_add('article');
  return $form;
}
added 352 characters in body
Source Link
niksmac
  • 7.7k
  • 3
  • 31
  • 69

How can I add content in modal form ? update I

I try this but not work for me,

function mymodule_menu() { $items = array();

$items['mymodule/page'] = array( 'page callback' => 'mymodule_page', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

$items['mymodule/%ctools_js'] = array( 'page callback' => 'mymodule_callback', 'page arguments' => array(1), 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

return $items; }

/**

  • Helper function to make a link. */ function _mymodule_make_link($link_text = '') { // Set a default value if no text in supplied. if (empty($link_text)) { $link_text = 'Magical Modal'; }

return '' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . ''; }

/**

  • An example page. */ function mymodule_page() { // Load the modal library and add the modal javascript. ctools_include('modal'); ctools_modal_add_js(); return _mymodule_make_link('Magical modal'); }

/**

  • Ajax menu callback. */ function mymodule_callback($ajax) { if ($ajax) { ctools_include('ajax'); ctools_include('modal');

    $form_state = array( 'ajax' => TRUE, 'title' => t('MyModule Modal Form'), );

    // Use ctools to generate ajax instructions for the browser to create // a form in a modal popup. $output = ctools_modal_form_wrapper('mymodule_form', $form_state);

    // If the form has been submitted, there may be additional instructions // such as dismissing the modal popup. if (!empty($form_state['ajax_commands'])) { $output = $form_state['ajax_commands']; }

    // Return the ajax instructions to the browser via ajax_render(). print ajax_render($output); drupal_exit(); } else { return drupal_get_form('mymodule_form'); } }

/**

  • Drupal form to be put in a modal. */ function mymodule_form(&$form, $form_state) { module_load_include('inc', 'node', 'node.pages'); $form = node_add('article'); return $form; }
function mymodule_menu() {
  $items = array();
 
  $items['mymodule/page'] = array(
    'page callback' => 'mymodule_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  $items['mymodule/%ctools_js'] = array(
    'page callback' => 'mymodule_callback',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  return $items;
}


/**
 * Helper function to make a link.
 */
function _mymodule_make_link($link_text = '') {
  // Set a default value if no text in supplied.
  if (empty($link_text)) {
    $link_text = 'Magical Modal';
  }
 
  return '<div id="magical-modal-link">' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . '</div>';
}



/**
 * An example page.
 */
function mymodule_page() {
  // Load the modal library and add the modal javascript.
  ctools_include('modal');
  ctools_modal_add_js();
  return _mymodule_make_link('Magical modal');
}



/**
 * Ajax menu callback.
 */
function mymodule_callback($ajax) {
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');
 
    $form_state = array(
      'ajax' => TRUE,
      'title' => t('MyModule Modal Form'),
    );
 
    // Use ctools to generate ajax instructions for the browser to create
    // a form in a modal popup.
    $output = ctools_modal_form_wrapper('mymodule_form', $form_state);
 
    // If the form has been submitted, there may be additional instructions
    // such as dismissing the modal popup.
    if (!empty($form_state['ajax_commands'])) {
      $output = $form_state['ajax_commands'];
    }
 
    // Return the ajax instructions to the browser via ajax_render().
    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('mymodule_form');
  }
}



/**
 * Drupal form to be put in a modal.
 */
function mymodule_form(&$form, $form_state) {
  module_load_include('inc', 'node', 'node.pages');
$form = node_add('article');
  return $form;
}

How can I add content in modal form ? update I try this but not work for me,

function mymodule_menu() { $items = array();

$items['mymodule/page'] = array( 'page callback' => 'mymodule_page', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

$items['mymodule/%ctools_js'] = array( 'page callback' => 'mymodule_callback', 'page arguments' => array(1), 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

return $items; }

/**

  • Helper function to make a link. */ function _mymodule_make_link($link_text = '') { // Set a default value if no text in supplied. if (empty($link_text)) { $link_text = 'Magical Modal'; }

return '' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . ''; }

/**

  • An example page. */ function mymodule_page() { // Load the modal library and add the modal javascript. ctools_include('modal'); ctools_modal_add_js(); return _mymodule_make_link('Magical modal'); }

/**

  • Ajax menu callback. */ function mymodule_callback($ajax) { if ($ajax) { ctools_include('ajax'); ctools_include('modal');

    $form_state = array( 'ajax' => TRUE, 'title' => t('MyModule Modal Form'), );

    // Use ctools to generate ajax instructions for the browser to create // a form in a modal popup. $output = ctools_modal_form_wrapper('mymodule_form', $form_state);

    // If the form has been submitted, there may be additional instructions // such as dismissing the modal popup. if (!empty($form_state['ajax_commands'])) { $output = $form_state['ajax_commands']; }

    // Return the ajax instructions to the browser via ajax_render(). print ajax_render($output); drupal_exit(); } else { return drupal_get_form('mymodule_form'); } }

/**

  • Drupal form to be put in a modal. */ function mymodule_form(&$form, $form_state) { module_load_include('inc', 'node', 'node.pages'); $form = node_add('article'); return $form; }

How can I add content in modal form ?

I try this but not work for me,

function mymodule_menu() {
  $items = array();
 
  $items['mymodule/page'] = array(
    'page callback' => 'mymodule_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  $items['mymodule/%ctools_js'] = array(
    'page callback' => 'mymodule_callback',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  return $items;
}


/**
 * Helper function to make a link.
 */
function _mymodule_make_link($link_text = '') {
  // Set a default value if no text in supplied.
  if (empty($link_text)) {
    $link_text = 'Magical Modal';
  }
 
  return '<div id="magical-modal-link">' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . '</div>';
}



/**
 * An example page.
 */
function mymodule_page() {
  // Load the modal library and add the modal javascript.
  ctools_include('modal');
  ctools_modal_add_js();
  return _mymodule_make_link('Magical modal');
}



/**
 * Ajax menu callback.
 */
function mymodule_callback($ajax) {
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');
 
    $form_state = array(
      'ajax' => TRUE,
      'title' => t('MyModule Modal Form'),
    );
 
    // Use ctools to generate ajax instructions for the browser to create
    // a form in a modal popup.
    $output = ctools_modal_form_wrapper('mymodule_form', $form_state);
 
    // If the form has been submitted, there may be additional instructions
    // such as dismissing the modal popup.
    if (!empty($form_state['ajax_commands'])) {
      $output = $form_state['ajax_commands'];
    }
 
    // Return the ajax instructions to the browser via ajax_render().
    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('mymodule_form');
  }
}



/**
 * Drupal form to be put in a modal.
 */
function mymodule_form(&$form, $form_state) {
  module_load_include('inc', 'node', 'node.pages');
$form = node_add('article');
  return $form;
}
added 2126 characters in body; added 360 characters in body; deleted 360 characters in body
Source Link
Yuseferi
  • 22.2k
  • 22
  • 118
  • 218

I want to load content form (example article content type ) in modal.

As Modal module allow to open forms in modal, but by default it given this feature to some of the form. My question is how can I use this module to add other content type forms.

How can I add content in modal form ? update I try this but not work for me,

function mymodule_menu() { $items = array();

$items['mymodule/page'] = array( 'page callback' => 'mymodule_page', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

$items['mymodule/%ctools_js'] = array( 'page callback' => 'mymodule_callback', 'page arguments' => array(1), 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

return $items; }

/**

  • Helper function to make a link. */ function _mymodule_make_link($link_text = '') { // Set a default value if no text in supplied. if (empty($link_text)) { $link_text = 'Magical Modal'; }

return '' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . ''; }

/**

  • An example page. */ function mymodule_page() { // Load the modal library and add the modal javascript. ctools_include('modal'); ctools_modal_add_js(); return _mymodule_make_link('Magical modal'); }

/**

  • Ajax menu callback. */ function mymodule_callback($ajax) { if ($ajax) { ctools_include('ajax'); ctools_include('modal');

    $form_state = array( 'ajax' => TRUE, 'title' => t('MyModule Modal Form'), );

    // Use ctools to generate ajax instructions for the browser to create // a form in a modal popup. $output = ctools_modal_form_wrapper('mymodule_form', $form_state);

    // If the form has been submitted, there may be additional instructions // such as dismissing the modal popup. if (!empty($form_state['ajax_commands'])) { $output = $form_state['ajax_commands']; }

    // Return the ajax instructions to the browser via ajax_render(). print ajax_render($output); drupal_exit(); } else { return drupal_get_form('mymodule_form'); } }

/**

  • Drupal form to be put in a modal. */ function mymodule_form(&$form, $form_state) { module_load_include('inc', 'node', 'node.pages'); $form = node_add('article'); return $form; }

I want to load content form (example article content type ) in modal.

As Modal module allow to open forms in modal, but by default it given this feature to some of the form. My question is how can I use this module to add other content type forms.

How can I add content in modal form ?

I want to load content form (example article content type ) in modal.

As Modal module allow to open forms in modal, but by default it given this feature to some of the form. My question is how can I use this module to add other content type forms.

How can I add content in modal form ? update I try this but not work for me,

function mymodule_menu() { $items = array();

$items['mymodule/page'] = array( 'page callback' => 'mymodule_page', 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

$items['mymodule/%ctools_js'] = array( 'page callback' => 'mymodule_callback', 'page arguments' => array(1), 'access callback' => TRUE, 'type' => MENU_CALLBACK, );

return $items; }

/**

  • Helper function to make a link. */ function _mymodule_make_link($link_text = '') { // Set a default value if no text in supplied. if (empty($link_text)) { $link_text = 'Magical Modal'; }

return '' . l($link_text, 'mymodule/nojs', array('attributes' => array('class' => 'ctools-use-modal'))) . ''; }

/**

  • An example page. */ function mymodule_page() { // Load the modal library and add the modal javascript. ctools_include('modal'); ctools_modal_add_js(); return _mymodule_make_link('Magical modal'); }

/**

  • Ajax menu callback. */ function mymodule_callback($ajax) { if ($ajax) { ctools_include('ajax'); ctools_include('modal');

    $form_state = array( 'ajax' => TRUE, 'title' => t('MyModule Modal Form'), );

    // Use ctools to generate ajax instructions for the browser to create // a form in a modal popup. $output = ctools_modal_form_wrapper('mymodule_form', $form_state);

    // If the form has been submitted, there may be additional instructions // such as dismissing the modal popup. if (!empty($form_state['ajax_commands'])) { $output = $form_state['ajax_commands']; }

    // Return the ajax instructions to the browser via ajax_render(). print ajax_render($output); drupal_exit(); } else { return drupal_get_form('mymodule_form'); } }

/**

  • Drupal form to be put in a modal. */ function mymodule_form(&$form, $form_state) { module_load_include('inc', 'node', 'node.pages'); $form = node_add('article'); return $form; }
Notice added Draw attention by Yuseferi
Bounty Started worth 50 reputation by Yuseferi
Tweeted twitter.com/#!/StackDrupal/status/419055339594862592
Source Link
Yuseferi
  • 22.2k
  • 22
  • 118
  • 218
Loading