Jumat, 11 Juni 2010

Menciptakan module Hello World pada Drupal Framework

Pertama sekali yang kita lakukan yakni membuat sebuat module baru yang bernama helloworld.module

Setelah itu,silahkan ketik syntax berikut di dalamnya :



function helloworld_help($path, $arg) {
  switch ($path) {
    case 'helloworld':
      return ''. t('ini akan menampilkan Help Hook. Ini adalah modul yang sederhana untuk mencetak "Hello World".') .'
';
  }
}

/**
 * Implementasi dari hook_perm().
 */
function helloworld_perm() {
  return array('access helloworld');
}

/**
 * Implementasi of hook_menu().
 */
function helloworld_menu() {
  $items = array();

  $items['helloworld'] = array(
    'title' => 'Hello World Olind',
    'description' => 'Hello World!.',
    'page callback' => 'helloworld_all',
    'access arguments' => array('access helloworld'),
    'type' => MENU_NORMAL_ITEM
  );
  return $items;
}

/**
 * Menampilkan teks "Hello World" kepada browser
 */
function helloworld_all() {
  return t("Hello, World dari Olind!");
}

/**
 * Implementasi of hook_block().
 */
function helloworld_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == "list") {
    $block = array();
    $block[0]["info"] = t('helloWorld');
    return $block;
  }
  elseif ($op == 'view' && user_access('helloworld')) {
    $block_content = 'ini block sederhana yang menampilkan "Hello World".
';

    $block['subject'] = 'Hello World Ajah';
    $block['content'] = $block_content;
    return $block;
  }
}
?>

dan ingat jangan lupa membuat file baru bernama helloworld.info dengan isinya sebagai berikut :

; $Id$
name = helloWorld
description = ini modul sederhana yang menampilkan "Hello World"
core = 6.x
package = "My Project"


mudah bukan ???? :)  

2 komentar:

  1. bngung euy..
    beda drupal ma joomla apa cih??
    kan sama2 cms

    BalasHapus
  2. yapzzz.. bedanya,Drupal lebih seru dengan permainan single sign on.. yang bisa melakukan login ke lebih dari satu situs.. itu salah satunya..

    BalasHapus