Hi,

I was able to get this module to work fine in an old test site which was using Drupal 7.4. However it is causing problems now I have updated to Drupal 7.8. When I enable this module I get a blank screen when I try to access;

- /admin/config/content/formats/full_html (Full HTML text format page, so I can't set up the site to use this module).
- The pages where you edit content of a block.
- The views editing pages.

I don't know if it is just me that is getting this, or it is a known issue. But this is a good module and I would like help with with this issue.

Cheers,

Comments

scottyboyearl’s picture

I managed to get it to work. I switched to the 7.x-2.3 version and in the .MODULE file I removed the section of code between lines 586 and 612. These lines contained the code shown below.

/**
* add the collapse.js file if needed.
*
* This is probably the wrong method to take. This may be more intensive than just
* adding the library to everything, and may mess with aggregated files (?).
*
* I have no idea what the right thing to do here is.
*
* based on #947710, jrockowitz
*/
function collapse_text_preprocess_page (&$variables) {
// if collapse.js is not already included
if ( strpos(drupal_get_js(), 'misc/collapse.js') == FALSE ) {
// see if we need to add it
$found = FALSE;
// ** there is some kind of recursion issue; the mucking with warnings is to
// ** suppress a whole lot of notifications...
$error_level = error_reporting();
error_reporting($error_level ^ E_WARNING);
array_walk_recursive($variables['page'], '_collapse_text_preprocess_page_walk_callback', &$found);
error_reporting($error_level);
if ($found) {
// and if we do, then do so...
drupal_add_library('system', 'drupal.collapse');
}
}
}

I hope this helps others.

Cheers.

Kman2123’s picture

same issue. I had to disable to get to some admin pages :(

joel_osc’s picture

For others that may be seeing this issue that part of the code will generate the following error message:

Warning: array_walk_recursive(): recursion detected in collapse_text_preprocess_page() (line 605 of /var/www/ctai/sites/all/modules/collapse_text/collapse_text.module).

refman1073’s picture

As the code comments in that section indicate the array walk of the page structure is not the best way to solve the javascript problem. I think I have a better approach. I believe that filter functions are only used on text fields, so scan the text field values when the field is attached for viewing using hook_field_attach_view_alter(). This solves the problem for me.

1. Delete the collapse_text_preprocess_page and _collapse_text_preprocess_page_walk_callback functions.
2. Add the following code as a replacement:

function collapse_text_field_attach_view_alter(&$output, $context) {
  $match = array();
  $regex = '/(?<!\\\\)\[\/?collapse[^\]]*\]/sm';

  foreach (element_children($output) as $field_name) {
    $element = &$output[$field_name];
    if ($element['#field_type'] == 'text_with_summary' ||
        $element['#field_type'] == 'text') {
      foreach ($element['#items'] as $delta => $item) {
        if (preg_match($regex, $item['value'], $match, PREG_OFFSET_CAPTURE)) {
          drupal_add_library('system', 'drupal.collapse');
          return;
        }
      }
    }
  }
}
joel_osc’s picture

Tested above code...seems to work well.

pukku’s picture

Status: Active » Fixed

Closing because it will be fixed with the release which fixes the others...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.