August 27, 2012

Create your first "Hello World" Drupal 7 module with the following steps.

  1. Create a folder called helloworld in sites/all/modules/custom
  2. Create a helloworld.info file
  3. Create a template file page-helloworld.tpl.php in your theme directory
  4. Enable your module at http://domain.com/admin/build/modules
  5. Visit http://domain.com/helloworld

This belongs into your helloworld.info file:

; $Id$
 
name = helloworld
description = Reinholds Hello World module
package = Reinholds modules
core = 7.x
 
files[] = helloworld.module

The helloworld.module file

<?php
 function helloworld_menu(){
   $items = array();
 
   $items['helloworld'] = array(
     'title'            => t('Hello world'),
     'page callback'    => 'helloworld_output',
     'access arguments' => array('access content'),
   );
 
   return $items;
 }
 
 /*
 * Display output
 */
 function helloworld_output() {
   header('Content-type: text/plain; charset=UTF-8');
   header('Content-Disposition: inline');
   return 'helloworld';
 }
?>

The theme template file page-helloworld.tpl.php

<?php
print $content;
?>

14 comments:

  1. Drupal has a well established reputation for running enterprise-level websites such as The Economist©, FedEx© and The White House. Drupal has an excellent vocabulary and a tag management core module with a better caching system. This is a key requirement to surpass the high volume of traffic.

    Drupal Hosting I Drupal Cloud Hosting

    ReplyDelete
  2. Thanks for posting the tips.

    Once i have got unseccess in development of this modules when i was new in the industry and took help from Drupal Web Developer for complete that task. But this time i seen this so thought i was supposed to do that at that time.

    ReplyDelete
  3. Drupal development is one of the best module in CMS for theme development. You mentioned the details stpes, it help the needy.

    psdtodrupaldeveloper.com

    ReplyDelete
  4. I recently came across your blog and have been reading along. I think I will leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

    PHP Shopping Cart

    ReplyDelete
  5. Nice Post.. Hey you can create you custom module with Drupal Development. you can create your website in affordable price. More info visit on http://markupzone.com/psd-to-drupal.html

    ReplyDelete
  6. Great post and its a great discussion on Drupal custom module.Drupal is a powerful module in open source content management system. Anyone can freely join with us for Software development in Drupal, Joomla and wordpress, software design, software application development in affordable price. More info visit on http://www.datainfovision.com

    ReplyDelete
  7. Drupal is used to built truly flexible E Commerce websites and applications. It stack provides one click solution for installation. we can run in own server drupal by virtual machines and download installer. Professional Website Design Company Bangalore

    ReplyDelete
  8. Choosing your CMS is very essential moving forward. I am a big fan of Drupal. Because Considering the leading websites like the UN use Durpal, I chose Drupal For a development platform I always use GetPantheon including features like fast cache responses which content management system do you prefer?

    Drupal for Education

    ReplyDelete
  9. Thanks for sharing such useful information... I think this is really a very nice post. Thanks for the great content!! find Custom Drupl Development company

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Terrific paintings! This is the type of information that should be allocated across the net. Disgrace on the search engines for no more positioning this post higher! Come on over and analyze out my website. Thanks

    Magento Development Company Bangalore | Drupal Development Company Bangalore

    ReplyDelete
  12. I would like to say thanks for your sharing this useful information. Nice post keep it up. Hope to see you next post again soon.

    With Regards,
    Ecommerce Web Development Company in Bangalore

    ReplyDelete