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
2010-09-25 17:49:58
A:
I'm the OP (but just registered an account).
I did manage to find a solution/workaround. Here's what I did:
- Create block.tpl.php in my module which is a copy from system/block.tpl.php, with a constant added at the top.
- 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(); }
- Checked for the constant while constructing the filter output, changing as necessary.
- Celebrated the outcome.
Jovean
2010-10-07 07:26:51
Actually, this doesn't work. Besides it trashed EVERY block, not just the ones where my filter was doing it's job ...
Jovean
2010-10-07 19:02:10