I have installed Drupal 7. I created new module (.module file and .info file), enabled the module, and gave the permission to menu item also. If I go to localhost/siva/shop/catalog/products, it redirects to the home page.

function displayproducts_menu() {
  $items = array();

  $items['shop/catalog/products'] = array(
    'title' => 'Products',
    'description' => 'Configure the cart page display and settings.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('displayproducts_show_form'),
    'access arguments' => array('view displayproducts'),
    'file' => 'uc_cart.admin.inc',
  return $items;

function displayproducts_permission() {
  $perms = array(
    'view displayproducts' => array(
      'title' => t('view displayproducts'),

  return $perms;

function displayproducts_show_form(){
    echo "hello world";

Why does this happens?

  • Did you clear your cache? When I create modules, 99% of times this problem is related to the cache not being cleared. When you modify the menu structure of your module you need to clear the cache. If you use drush then in the command line try drush cc all; if you don't use Drush then clear the cache from your admin menu (admin/config/development/performance). Dec 24, 2014 at 22:45
  • 1
    I don't know what the effect will be of not returning a $form element when using drupal_get_form. So instead of just echoing output, return a $form element, even if it is just an empty array(). Dec 25, 2014 at 4:56
  • I agree with @J.Reynolds here: A form builder is supported to return a form array, not echoing a string. Change the code, and try again after you cleared the cache.
    – apaderno
    Dec 25, 2014 at 11:19

1 Answer 1


You form function callback is incorrect you need to return a valid form, try this code:

function displayproducts_show_form($form, &$form_state){
  $form['item1'] = array(
   '#markup' => "hello world",
  // @TODO: include more form items.
  return $form;

Documentation: FAPI

Make sure that this function is in your uc_cart.admin.inc file as you indicate in the hook menu declaration: 'file' => 'uc_cart.admin.inc', if it is in your main module file (.module) remove this line and clear the caches again.

  • Does not returning anything cause the behavior the OP is seeing? If you have any reference about this, please add them.
    – apaderno
    Dec 25, 2014 at 11:20

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.