This beginners tutorial shows how to create a durpal module. We will set up a module, create a menu item and a "Hello World" page.
Folder for our module
Create new folder in sites/all/modules directory. My module name is Hello World so I'll name the folder to hello_world.Info file
Create a new file called hello_world.info.If you use drupal 6 not 7 then remove files variable and change core to 6.x.Source code viewer
; $Id: hello_world.info name = Hello World description = "Hello World page." core = 7.x files[] = hello_world.moduleProgramming Language: YAML
PHP file
You can access the page from http://example.com/admin/hello_world. Don't forget to enable the module and if you make changes in function names then you have to clear drupals cache.Source code viewer
<?php /** * Implementation of hook_menu(). */ function hello_world_menu() { 'title' => 'Hello World', // page title 'page callback' => 'hello_world_page', // function that is called when you land to this url 'access callback' => TRUE, // always and everybody can access this url 'type' => MENU_CALLBACK, // no menu item will be made, simple callback is made ); return $items; } /** * Page callback. */ function hello_world_page() { /** If you return you get you content in Drupal if you echo you get your results in plain html. This way you can output xml or what ever content you might need */ return 'Hello, World!'; }Programming Language: PHP