1

i had create one block in my custom module, which display in "CONTENT" region, only on "currant-trustees" page.

when i access url "localhost/drupal/currant-trustees" page is render correctly, but with error "The requested page "/drupal/currant-trustees" could not be found." and also page title is page not found.

6
  • 1
    have you created a page named as currant-trustees?
    – DRUPWAY
    Sep 18, 2014 at 5:54
  • no i create block using template file Sep 18, 2014 at 5:57
  • 1
    you have to create a basic page first named as current-trustees and then render the block in that page.
    – DRUPWAY
    Sep 18, 2014 at 5:59
  • i mean first i register block using hook_block_info(), then register template using hook_theme() and finally assign content using hook_block_view() with template file. Sep 18, 2014 at 6:00
  • page is rendered as per my requirement but problem is it display error page could not be found Sep 18, 2014 at 6:03

2 Answers 2

1

It sounds to me like you only want to show said block on that page and nothing else. You might be better off implementing hook_menu() to register a callback (a page) which displays custom content, instead of creating an empty page and showing a block on that.

It might look something like this:

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {
  $items['currant-trustees'] = array(
    'page callback' => 'MYMODULE_currant_trustees',
    'title' => 'Currant trustees',
    'type' => MENU_CALLBACK,
  );
  return $items;
}
function MYMODULE_currant_trustees() {
  $content = 'This is where your content should go, just copy the code from the block content';

  return $content;
}
1
  • Yes you are right when we wants to display only that block in page content region than your solution is perfect. Sep 19, 2014 at 9:46
0

The problem is i just registered block with specific page/url, but there is no any page/url on which drupal going to display block, so first i need to register page/url in drupal so create one page and than display block on that page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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