I have made the block and want it to be clickable(entire block) and we can provide the path to it?

Note: There is other question with same heading but it does not provide the answer and it is in context of views.

1 Answer 1


In the template.php, add an "onclick" attribute with theme_preprocess_block:

function mytheme_preprocess_block(&$variables, $hook) {
  if ($variables['block']->delta == "my-viewblock-name") {

Then, in a .js file you add

function my_click-routine(){
  // Do whatever you want here, e.g. show the "page view" when clicking on the block view;

This makes the entire block clickable. You can also do more than just navigate to another page.

  • Hi, I am not too familiar with codes. I added as you suggested, correct me if I am missing something. 1. added the first code of your answer as it is in the template.php. 2. Made the js folder in the theme and made the new js file and pasted the second code, made the path in .info file 3. May be I need to give the location of the block, so in js file document.location I changed it to 'document.#block-block-9` which is the ID of block......and cleared the cache.....but it is not working...Please correct what other thing needed..Thanks
    – CodeNext
    Dec 2, 2015 at 10:25
  • #block-block-9 is it view block?? Dec 2, 2015 at 11:54
  • No, it is not a view block, it is a simple drupal block and css ID (#block-block-9)which i got is automatically generated by drupal.
    – CodeNext
    Dec 2, 2015 at 12:04
  • this in same page or in other page Dec 2, 2015 at 12:33
  • Hi, I did not get the "page" thing, moreover in answer page or how to describe particular page is not mentioned.
    – CodeNext
    Dec 2, 2015 at 12:37

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .