[support] Trouble adding a class to a ctools modal D7

Jeff Greenberg listmail.ayendesigns at gmail.com
Mon Nov 18 22:23:43 UTC 2013


I'm running into css issues theming a ctools modal popup, because there
isn't a class or id in it specific to its context... that is, any ctools
modal popup on the site has the same ones.

So, I'm trying to theme it so that I can add a class, and am going by what
I see in its own example as well as one of the better ones I found, here:
http://drupion.com/blog/10-steps-creating-ctools-modal-window-drupal-7

The code I have is below. The js from the module that process the modal
fires (I put an alert at the start of it), but for some reason its contents
are never used instead of the ctools default html.

function mymod_callback($ajax, $nid) {
  $_SESSION['nid'] = $nid;
  if ($ajax) {
    ctools_include('ajax');
    ctools_include('modal');

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

    $output = ctools_modal_form_wrapper('mymod_form', $form_state);

    if (!empty($form_state['ajax_commands'])) {
      $output = $form_state['ajax_commands'];
    }

    print ajax_render($output);
    drupal_exit();
  }
  else {
    return drupal_get_form('mymod_form');
  }
}

function mymod_make_share_link($nid) {
  ctools_include('ajax');
  ctools_include('modal');
  return
ctools_modal_image_button(file_create_url('public://icons/myimg.png'),
'myform/' . $nid . '/nojs', t('title'), 'ctools-modal-mymodal-style');
}

Then in the page pre-process

  ctools_include('modal');
  ctools_modal_add_js();
  $mymodal_style = array(
    'mymodal-style' => array (
      'modalTheme' => 'myModal',
    )
  );
  drupal_add_js($mymodal_style, 'setting');
  ctools_add_js('mymodal', 'mymod');
  ctools_add_css('mymodal', 'mymod');
}

And finally, in the js file

  (function ($) {
    Drupal.theme.prototype.myModal = function () {
      var html = ''
      html += '  <div id="ctools-modal" class="mymodal">'
... other markup

      return html;
    }
  })(jQuery);

-- 
---
drupal.org/user/367108
linkedin.com/in/jeffrgreenberg
accidentalcoder.com / ayendesigns.com
@accidentalcoder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20131118/d340f696/attachment.html 


More information about the support mailing list