As has been mentioned in several threads there are several forked versions, most recently: https://github.com/jlyon/ctools_automodal that have added many new features, and api.php file, and an example module. I'm not sure how or why these features have been added to projects outside this one but it would be great to get the latest code onto Drupal.org. Yet again today I pointed someone who needed a modal solution to that github account instead of this one. Let's fix that!

Attached is a patch that merges the changes from that account into this project.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

acouch’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, ctools-automodal-githubfeatures.patch, failed testing.

jlyon’s picture

Hmm. Which branch of ctools_automodal did you create this from? I'm getting the error below when I try to apply it to either ctools_automodal-7.x-1.1 and ctools_automodal-7.x-dev:

$ git apply -v < ctools-automodal-githubfeatures.patch
Checking patch ctools_automodal.api.php...
Checking patch ctools_automodal.module...
error: while searching for:
 * Implements hook_menu_alter().
 */
function ctools_automodal_menu_alter(&$items) {
  $modal_paths = array();

  foreach ($items as $path => $item) {
    if (!empty($item['modal']) && strpos($path, '%ctools_js') === FALSE) {
      if ($item['page callback'] == 'drupal_get_form') {
        $items["$path/%ctools_js"] = $item;
        $items["$path/%ctools_js"]['page callback'] = 'ctools_automodal_get_form';
        $items["$path/%ctools_js"]['page arguments'][] = substr_count($path, '/') + 1;
        $items["$path/%ctools_js"]['type'] = ENU_CALLBACK;
      }
      else {
        $items["$path/%ctools_js"] = $item + array('page arguments' => array());
        $items["$path/%ctools_js"]['page callback'] = 'ctools_automodal_get_page';
        array_unshift($items["$path/%ctools_js"]['page arguments'], $item['page callback']);
        $items["$path/%ctools_js"]['page arguments'][] = substr_count($path, '/') + 1;
        $items["$path/%ctools_js"]['type'] = ENU_CALLBACK;
      }
      $modal_paths[] = preg_replace('/%[^\/]*/', '*', $path);
    }
  }

  variable_set('ctools_automodal_paths', $modal_paths);
}

/**
 * Check if an internal Drupal path should be converted to a modal link.
 */
function ctools_automodal_is_path_modal($path) {
  static $modal_paths_regex;

  if (!isset($modal_paths_regex)) {
    $modal_paths = variable_get('ctools_automodal_paths', array());
    foreach ($modal_paths as &$modal_path) {
      $modal_path = preg_quote($modal_path, '/');
      $modal_path = str_replace('\*', '.*', $modal_path);
    }
    $modal_paths_regex = '/^(' . implode('|', $modal_paths) . ')$/';
  }

  return (bool) preg_match($modal_paths_regex, $path);
}

/**

error: patch failed: ctools_automodal.module:16
error: ctools_automodal.module: patch does not apply
Checking patch ctools_automodal_example/ctools_automodal_example.info...
Checking patch ctools_automodal_example/ctools_automodal_example.module...
acouch’s picture

Status: Needs work » Needs review
FileSize
27.01 KB

Sorry about that, can you try the attached?

wojtha’s picture

Just for the record.

I'm not sure how or why these features have been added to projects outside this one

I've started the first fork at github and I did it because Dave Reid was overwhelmed at that time so I knew there will be no progress for the next couple of months. I had been trying to contribute with patches before, but got zero feedback. So I decided to do a temporary fork.

And why at github and not at drupal.org as a sandbox project? Because I can delete it when the changes will be merged to the main project. Drupal.org sandboxes cant be deleted at this time...

I've clearly declared my decision here: #1420534-3: Consider a new hook - hook_ctools_automodal_paths() rather than using hook_menu()

acouch’s picture

Thanks wothja. I was only trying to saw that I wasn't involved in that initial forking. There are many parties that would like to get this back onto drupal.org.

j0rd’s picture

Looking forward to your work with this. Based on the age of ctools_automodal, one of you guys should ask Dave Reid for co-maintainer status and setup a 2.x branch (core functionality changes in this branch warrant it).

Currently ctools_automodal 1.1 is causing problems all sorts of problems with other custom javascript due to an over-zealous ctools_automodal_page_delivery_callback_alter(), so I'm looking for another solution.

There's a good ctools patch, which is important for people using this as their main popup dialog
#1294478: Modal dialog dynamic resizing

Until this ends up in ctools, it's perhaps something that could get added to this branch of ctools_automodal. Removes the requirement of having to create endless hook_modal_styles(). I've been using the dynamic patch and it's been working great so far.

capellic’s picture

Status: Needs review » Reviewed & tested by the community

I too am using the patched version of of the forked and dev branch... it works great!!! Let's get this into the Dev release, please!

Just to note, the way you get a path to get detected by the module is different from the documentation on the project page... 'modal' => TRUE is dead

Instead, you need to implement the hook_modal_paths() and hook_modal_styles() functions. Once you know that, you're good to go.

jlyon’s picture

I have been using this patch with success as well. Should we add support for the old 'modal' => TRUE method with a ctools_automodal_modal_paths() call?

capellic’s picture

@jlyon, It might be nice to support 'modal' => TRUE to make it easier to implement for some people and in some cases. But if that causes undue grief for module maintainers, then never mind.

greggles’s picture

Sign me up as another person running the github fork instead of the main one.

At a minimum I suggest adding that as a new branch here.

mathieso’s picture

+1. I'm using the github fork, too.

Kieran