0

I have a custom input filter module, and I am trying to figure out why it crashes when I attempt to insert a block into a post via a shortcode. The method works perfectly when I am inserting a string, but when I try to insert a block, it causes a http 500 error.

Any ideas? I am using Drupal 7.15. Also, I have tried the insert_block module, and it generates a similar error...

Here is the input filter process that works (with a string)

function _related_links_filter_related_block_process($text, $filter, $format) {
   $shortcode_regexp  = "/\[block\]/";
   $output = "Text string inserted in via shortcode";

   return preg_replace($shortcode_regexp, $output,$text);
}

Here is the input filter process that causes the error (with a block)

function _related_links_filter_related_block_process($text, $filter, $format) {
   $shortcode_regexp  = "/\[block\]/";
   $block = block_load('block', 3);
   $output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));

   return preg_replace($shortcode_regexp, $output,$text);
}

Any help is appreciated!

0

A 500 error can be caused by lots of things. Your best bet is probably to use the Watchdog and/or Apache logs to narrow down the specific cause(s).

| improve this answer | |
0

Figured out a way to do it without the 500 error, I tried loading a block in a different way and it worked. Don't know why module_invoke() works over block_load(), if someone can explain.

function _related_links_filter_related_block_process($text, $filter, $format) {
   $shortcode_regexp  = "/\[block\]/";
   $block = module_invoke('block', 'block_view', 3);
   $output = render($block['content']);

   return preg_replace($shortcode_regexp, $output,$text);
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.