Drupal – Introduction to Drupal Theming @ 1

The following module is an example which shows you the simplest way of Drupal themeing.

ykyuen.info

; $Id$
name = Theme customized block
description = Theme the customized block. Ref: http://ykyuen.wordpress.com
package = "YKYUEN"
core = 6.x
version = 6.x-1.0

 

ykyuen.module

<?php

/**
 * Implementation of hook_block().
 */
function ykyuen_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('Eureka');
      $blocks[0]['cache'] = BLOCK_NO_CACHE;
      return $blocks;
    case 'view':
      switch ($delta) {
        case 0: 
          $block['content'] = theme('eureka', 'Welcome to Eureka!', 'http://ykyuen.wordpress.com');
          break;
      }
      return $block;
  }
}

/**
 * Implementation of hook_theme().
 */
function ykyuen_theme() {
  return array(
    'eureka' => array(
      'arguments' => array(
        'name' => NULL,
        'link' => NULL
      )
    )
  );
}

/**
 * Implementation of theme_eureka().
 */
function theme_eureka($name, $link) {
  return "<a href=\"$link\">$name</a>";
}

 

Enable the module and then configure the block.

 

See what we get now.

 

Done =)

Next: Drupal – Introduction to Drupal Theming @ 2

Reference:

About these ads

2 thoughts on “Drupal – Introduction to Drupal Theming @ 1”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s