helloworld module with theming inside module?

marshallexcavating - January 28, 2009 - 01:23

Dose somebody have a good reference/advice as to how to implement a simple theme inside a module. I have goon through this forum, the create module tutorial drupal 6.x and I have been trying to implement chapter 4 of "learning drupal 6 module development" for a frustrating week.

I have made the following file(craigstest.module) in directory var/www/drupal/sites/all/modules/craigstest:

<?php
// $Id$

/**
* @file
* Module for displaying test.
* This module provides test block content.
*/

/**
* Implementation of hook_block
*/
function craigtest_block($op='list' , $delta=0, $edit=array()) {
  switch ($op) {
    case 'list':
      $blocks[0]['info'] = t('craigssss test module...');
      return $blocks;
    case 'view':
      $advice1 = "5";
$advice2 = "2";
$advice = $advice1+$advice2;
   
      $blocks['subject'] = t('Test module');
      $blocks['content'] = t($advice);
      return $blocks;
  }
}

/**

and file (craigstest.info) also in directory var/www/drupal/sites/all/modules/craigstest
; $Id$
name = "craigstest"
description = "test module."
core = 6.x
php = 5.0

The module simply adds 5+2 and shows the result (7) in a block. I am confused as to what file(css?+file?) and where(in what directory) to work the theme for this module? I am finding that the wording/nomenclature frustrating in Drupal.

I am simply trying to learn the ropes and what i would like to eventually do is make a module game or do a calculation not necessarily add any functionality to my drupal web site. Also hoping to implement JavaScript simply; but i am missing something with all this what file and where to place them (what directory).

Thank you for any help.

I'm not sure I understand

strands - January 28, 2009 - 05:22

I'm not sure I understand what you need - are you trying to theme the resulting block?
Typically this is done in sites/all/themes/[themename]/style.css.

To help you determine exactly what elements to style, install the Firefox Web Developer module (assuming you use FF).
Ctrl+Shift+y will display style information about the elements pointed to so that you know what to target in your CSS file.

yes I am trying to them only

marshallexcavating - January 28, 2009 - 06:33

yes I am trying to them only the block that my modual is displayed in seperatly than the drupal them. I want to controle the look of the block only.

Typically this is done in sites/all/themes/[themename]/style.css.

dose " themename" folder have to be named so that drupal sees it? or in my specific example would i make it "craigstest"?
dose style.css have to be this name or in my example craigstest.css and is it posible to use id and class to stile the t() function output?

stands thanks you for the Firefox web developer link I just installed it and when i look at the block "craigstest" it is saying the drupal them is controling this block.

thank you

The "themename" folder is

strands - January 28, 2009 - 07:04

The "themename" folder is the folder for the theme you are currently using - you can see which theme you are using under Administer, Site building, Themes. E.g. if you are using the Bluemarine theme then the stylesheet you need to alter is in sites/all/themes/bluemarine/style.css. Edit this file to target the element shown by the Web Developer module.

I suggest you review the theming documentation at http://drupal.org/theme-guide - it'll explain how themes work and should point you in the right direction.

Good luck.

 
 

Drupal is a registered trademark of Dries Buytaert.