I have a new text format sample_page with the filter sample_page, I've created using hook_filter_info(). In the callback, I am rendering a webform using depending on the token in the node body, for webform I'm planning to use a token [block:webform:webform-client-form-2423].
I could render the blocks created programmatically, system blocks. But not the blocks created by other modules, I have tried [block:user:login] from http://mine.local/admin/structure/block/manage/user/login/configure to render to login blocks too. But these blocks didnt seems to work. Here is my callback for filter.
System blocks that worked for me, I used the token [block:block:25] from http://mine.local/admin/structure/block/manage/block/2/configure and for blocks created programatically by my own module, suppose my module is my_module, I have used the token [block:my_module:block_name] from the url http://mine.local/admin/structure/block/manage/my_module/block_name/configure
preg_match_all('/\\[([a-zA-z0-9_\-]+:[a-zA-z0-9_\-]+)+\\]/m', $text, $match);
$matches = $match[0];
foreach ($matches as $token) {
$token_name = str_replace(array( '[', ']' ), '', $token);
$type = explode(':', $token_name);
if ($type[0] == 'block') {
$module = $type[1];
$bid = $type[2];
$block = block_load($module, $bid);
$replacement = render(_block_get_renderable_array(_block_render_blocks(array($block))));
}
}
Can any one look into the problem. Any help would be appreciated...