Pages

Thursday, February 24, 2011

Drupal Module - iPad Block

<?php

/**
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @version : 1.0
 * @date    : February 24, 2011
 * @type    : drupal module - block
 */
 

/**
 * This defines general setting for the module
 */
function ipad_block_info(){
    $block['ipad_apple'] = array(
        'info' => t('This is iPad module'),
        'cache' => DRUPAL_CACHE_PER_ROLE,
        'region' => 'sidebar_first',
        'visibility' => 1,
        'pages' => '*',
        'status' => TRUE,
    );
   
    return $block;
}

/**
 * This act as roles like an interface,
 * then implemented in the ipad_content
 */
function ipad_block_view($delta=''){
    switch($delta){
        case 'ipad_apple':
            $block['subject'] = t('Hello World');
            $block['content'] = ipad_content($delta);
            break;
    }
   
    return $block;
}

/**
 * This is what displayed in the content of block
 */
function ipad_content($switch_delta){

    $form['indonesia'] = array(
        '#type' => 'textfield',
        '#title' => 'Enter A Name',
        '#size' => 20,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Search',
    );
   
    switch($switch_delta){
        case 'ipad_apple':
            return $form;
    }
}

No comments:

Post a Comment