RSS Feed

‘drupal’ Category

  1. The one thing you need to know about building CMS themes

    November 10, 2010 by admin

    Does it support intelligent body classes?
    It will make your theming life so much easier, it’s absolutely ridiculous …

    Read about the WordPress version and the benefits of using this concept for theming purposes here: http://codex.wordpress.org/Template_Tags/body_class

    WordPress (2.8+):

    <body <?php body_class(); ?>>

    Drupal (originally from Zen Theme, since Drupal 6 in core):

    <body class="<?php print $body_classes; ?>">

    Joomla:

    Not available by default, must be built manually in template. The Joomla 1.6 version of the default Milkyway template uses something remotely similar for color and background parameters and template width.

    Magento:

    <body <?php echo $this->getBodyClass()?'class="'.$this->getBodyClass().'"':'' ?>>

  2. Create your first simple Drupal 7 module

    June 28, 2010 by admin

    Create your first 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;
    ?>

  3. Drupal 7 Themes – Browser specific CSS

    June 28, 2010 by admin

    In Drupal 6 you had to target IE specific CSS files by adding lines to your page.tpl.php or use an additional module which allows you to target browsers inside your theme.info file.

    In Drupal 7 however, the recommended way is by using the use drupal_add_css() function in your template.php file.

    function mytheme_preprocess_html(&$vars) {
      drupal_add_css(path_to_theme() . '/fix-ie.css', array('weight' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
    }