1

May be I am something obvious but a simple custom Hello world module isn't working. I have spent a couple of days trying to fix this but no progress at all.

hello_world.info

name = Hello World
description = "This module is to test hello world"
core = 7.x

hello_world.module

<?php
/**
* Implements hook_init()
*/

function oulta_hello_world_init() {
  drupal_set_message("From Hello World Module");
}

/**
* Implements hook_menu()
*/

function hello_world_menu() {
  $items['hello_world'] = array(
  'title' => 'Just saying hello world',
  'page callback' => 'hello_world_pg',
  'access callback' => TRUE,
  'type' => MENU_CALLBACK,
  );
  return $items;
}

function hello_world_pg() {
  drupal_set_message("Hello World page called");
  return 'Hello world!';
}

I am trying to access the page at localhost/mysite/hello_world/

The path for .module and .info files is htdocs/mysite/sites/all/modules/custom

Since hook_menu is fundamental to development, I am stuck. Please help.

BTW are there are alternatives for hook_menu for rendering pages?

Thanks in advance.

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
user2283993
  • 13
  • 1
  • 6

2 Answers2

2

Change your code to be

function hello_world_menu() {
  $items = array(); // define the $items array

  $items['hello_world'] = array(
  'title' => 'Just saying hello world',
  'page callback' => 'hello_world_pg',
  'access callback' => TRUE,
  'type' => MENU_CALLBACK,
  );
  return $items;
}

And then flush your website cache.

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
  • Thanks for the reply Muhammad but this didn't change the behavior. – user2283993 Sep 01 '14 at 16:23
  • What's inside the function `hello_world_pg()`? And what happens when you go to the page `/hello_world` – Muhammad Reda Sep 02 '14 at 07:51
  • And do you see any output message for `drupal_set_message("From Hello World Module");` inside your `hook_menu()` implementation ? – Muhammad Reda Sep 02 '14 at 07:56
  • No. All I see is the message as a result of the _init() function. Here's something interesting. – user2283993 Sep 03 '14 at 00:36
  • this is the message in the logs. PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'MENU_NORMAL_ITEM' for column 'type' at row 5: INSERT INTO {menu_router} (path, load_functions, to_arg_functions, access_callback, access_arguments, page_callback, page_arguments, delivery_callback, fit, number_parts, context, tab_parent, tab_root, title, title_callback, title_arguments, theme_callback, theme_arguments, type, description, position, weight, include_file) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1... – user2283993 Sep 03 '14 at 00:38
0

After trying out myriad solutions, it still didn't work. I came to a conclusion that this was a result of database corruption. Loaded an older database and Voila everything started working.

user2283993
  • 13
  • 1
  • 6