I have created a block for adding image from drupal backend with title name "image". Now i want to add this block into page.tpl. How can i do that by using code.

  • 1
    I'd advise doing it from admin/structure/block. Read this, espacially the comments, if you really want to do it in code.. – xurshid29 Oct 21 '14 at 9:09

Here is the sample code

$imageblock = block_load('block', '155');
$output =  drupal_render(_block_get_renderable_array(_block_render_blocks(array($imageblock))));

$output will have the generate html for the block . This can be rendered in the template file using

 print $output;

If the block is created using views, you may have to use $imageblock = block_load('views', 'block_name'); instead of loading the block using the block id.

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.