views:

18

answers:

2

I have a Drupal filter module whose output I would like to alter, depending on where the output is going to be displayed. Specifically, I want to the filter to give the full output for nodes, but trim the content down for blocks.

+1  A: 

I don't think this would be possible. It's hard enough to figure out what context something is being displayed in. It's doable but quite hard to code on your own. However the way the filter system works I don't think its possible within a filter to determine then context of the text being filtered. It's simply not made for something like that.

googletorp
A: 

I'm the OP (but just registered an account).

I did manage to find a solution/workaround. Here's what I did:

  1. Create block.tpl.php in my module which is a copy from system/block.tpl.php, with a constant added at the top.
  2. Put my template file at the head of the theme registry using hook_theme_registry_alter():
    function hook_theme_registry_alter(&$theme_registry) {
    // using our own block.tpl.php file.
    $theme_registry['block']['template'] = 'block';
    $theme_registry['block']['path'] = drupal_get_path('module', 'module_name');
    $theme_registry['block']['type'] = 'module';
    $theme_registry['block']['theme path'] = drupal_get_path('module', 'module_name');
    $theme_registry['block']['theme paths'] = Array();
    }
  3. Checked for the constant while constructing the filter output, changing as necessary.
  4. Celebrated the outcome.
Jovean
Actually, this doesn't work. Besides it trashed EVERY block, not just the ones where my filter was doing it's job ...
Jovean

related questions