Blogs tagged with: 'theming'

Blogs

  • David Needham
    1
    September 26, 2012

    Drupal can be complicated, but with that comes incredible power and flexibility. The Drupal theme system creates the perfect storm of complexity, UX and control from the interface. Drupal theming isn't easy, but even the layman can do incredible things through pointing and clicking. And if you want to do things The Drupal Way, it's vitally important to learn to let Drupal do what it can from the interface (before even thinking about touching code).

  • David Needham
    4
    January 17, 2012

    We all have to admit that CSS has some shortcomings. Thanks to the adoption of CSS3 and increasing standardization between browsers, this is getting better. During a recent course on responsive theming, I discovered a neat trick to trigger a click effect on elements in a mobile browser. It utilized the common css pseudo-class :hover, but when you add some CSS3 transitions it starts to get really interesting.

  • David Needham
    7
    November 09, 2011

    I consider use of a base theme to be Level 2 theming because this should mean that you've either grown enough or failed enough as a themer to want to do things the Drupal way. That means no longer hacking core and saving yourself a ton of hassle. You can let Drupal do the work for you and still make the theme your own!

    The Evolution of a Themer

  • David Needham
    5
    October 16, 2011

    In Level 1 we introduce the anatonmy of the theme and the files you'll find within. We walk through creating your own basic theme and introduce the concept of sub-theming.

    In the "evolution of a themer", this is where the fun really starts. Up until now you may have downloaded a contributed theme from Drupal.org, maybe you hacked the theme a bit to make it your own but you've never made your own theme. This blog post is all about reaching Level 1 and creating your own basic theme from scratch.

  • 15
    January 27, 2011

    I love theming Drupal sites. Yes, I realize that means I’m a super nerd. Drupal’s theme layer with its system of overrides is powerful. It works so well that I rarely need a starter theme, like Zen, Basic, Framework or NineSixty nowadays, other than as a reference and source of code snippets.

    What Starter Themes Do

    Drupal 6 saw a jump in the number of contributed starter themes on drupal.org. Now it’s much easier to find a list of all starter themes and there are a few great reviews and a comparison chart. Starter themes are a class of themes that attempt to generalize their features to speed up implementing a design for most any site, while encouraging best practices. They are popular among development teams since they help standardize theming when multiple people must touch the theme. They are also excellent demos of the power and potential of Drupal’s theme system, which makes them a great learning tool and source of documentation. Many starter themes are intended to be used as a base theme, where you create a sub-theme that draws off their files. This makes it easier to produce themes with fewer files and overrides, leaving the base/starter theme to do most of the heavy lifting.

    A closer review of contributed starter themes reveals some recurring features, including:

  • 16
    April 08, 2010

    Drupal 6 provides many avenues to modify its appearance, including ways to theme a form. Recently I themed all node edit forms at once. I will share here how I did it.

    The usual route to theme a node edit form, or any form for that matter, is to grab the form ID, which is used as a theme hook, and implement a hook_theme function in template.php in the theme.

    function MYTHEME_theme() { return array(
        'blog_node_form' => array(
          'arguments' => array('form' => NULL),
          'template' => 'blog-node-form',
        )
      );
    }
    ?>

    This lets you alter the theme registry to add a template file for a specific form. There are many blog posts that go into more detail than I do here on how to theme forms in general.

    The above is useful if I want to theme a blog content type or the user registration form, for example. Most sites have at least a few different content types. I wanted to make alterations to all node forms at once and use a single template file. This involved a slightly different approach.

    Correction: This next step with the theme_registry_alter example is not necessary. See comments below this post.

    There is a theme_node_form theme function in Drupal, which is called by all node forms. I wanted to replace or supersede this theme function with a template. I tried to do this with hook_theme, but it continued to pick up some parts of theme_node_form in addition to supporting my template file. So it called the form array twice, causing recursion; which is not what I expected. So instead I took a colleague's suggestion and altered the theme registry via hook_theme_registry_alter(). This seemed clean and simple enough.

    This takes the node_form theme hook and changes it from a theme function to a template, in sites/all/themes/MYTHEME/template.php:

    function MYTHEME_theme_registry_alter(&$theme_registry) {
      $theme_registry['node_form'] = array(
        'template' => 'node-form',
        'arguments' => array('form' => NULL)
      );
    }
    ?>

    This worked great. But I hear that hook_theme_registry_alter is intended for use in modules only? If you know why, please chime in with a comment. Or leave a comment on the theme registry for special cases handbook page.

    And the fun part... Spiffing up the node edit form

    Here is what I did. This creates two columns for the form and places all top level form fieldsets on the right.

    Screenshot:

    Screenshot of modified node edit form.

    And here is how I did it...

  • 22
    January 28, 2009

    Perusing the themes available on drupal.org reveals that there are over seven starter themes for Drupal 6 in addition to Zen, the original "starter" theme for Drupal. Starter or "base" themes are a class of themes that seek to provide best-practices starting points for themers to build unique designs. Most include a common set of features necessary for most sites, helping to minimize the repetition of a themer recreating many similar files, markup and code for each project.

  • Josh Koenig
    3
    August 16, 2008
    drupal, howto, theming

    Once of the biggest advances "under the hood" in Drupal 6 is the addition of the preprocess architecture to the theme layer. This is part and parcel with the deeper embedding of template files, and together they render Drupal 6 the most flexible and powerful release yet in terms of theme and design. For those of us who still do a fair amount of work with the 5.x branch, it's easy to be envious of those lucky enough to have these new tools at their disposal. But resist that cardinal sin!

  • June 08, 2008

    There comes a time in the life of every young child when begin to dress yourself. No longer are you content with the dorky collared shirt your mother laid out for you each morning or the matching shoes you and your siblings wore because it was just easier that way. Instead, you yearn for a little class, a little flash, and for the older kids some san francisco style.

  • Josh Koenig
    February 19, 2008

    With the release of Drupal 6.0, there have been major steps forward in the theme layer. Two of the most important are the standardization of template files and their associated pre-process functions, and the addition of theme.info files which allow the overriding of whole core stylesheets.