Book Image

Instant Premium Drupal Themes

By : Pankaj Sharma
Book Image

Instant Premium Drupal Themes

By: Pankaj Sharma

Overview of this book

Drupal’s theme layer, and the themes that use it, are responsible for the look and feel of a Drupal web site. Themes have the final say and ultimate control over almost every aspect of each page. Good themes consist of all the same elements that you would find on any reputable web site, including standards-compliant XHTML markup, CSS, and JavaScript. How it all comes together is what is so special and what makes Drupal themes so flexible and powerful. Premium Drupal Themes is a practical, hands-on guide filled with clear, step-by-step examples which shows you how to create Drupal themes using HTML. This book will show you the best practices and conventions that you should adopt and utilize so you can change the way Drupal looks using HTML without wasting energy digging through Drupal’s code. Starting with the essentials including Drupal terminology and Drupal theme structures, this book will show you how to configure raw HTML in a Drupal environment. You will learn about the Drupal template variables and also how to populate a Drupal theme with dynamic content. You will also discover how to customize the search result page and how to add regions to your home page. This book will help you familiarize yourself with the theme engines and will help you learn about the core of Drupal’s theme rendering system. Finally, you will learn how to create your very own Drupal theme that will take people’s breath away!
Table of Contents (7 chapters)

Configuring raw HTML in the Drupal environment (Simple)


How to configure a raw HTML file in a Drupal environment will be explained here in brief. Doing this is important as HTML will start displaying when this step will be followed.

Drupal is a CMS that understands everything that has been written as per its API. It is made up of various APIs and the Theme API handles everything about the theme. If a user places HTML files that are having user-defined names, Drupal is not going to understand that.

Filenames of a theme and variables used in themes should be as per the Drupal Theme API.

We will explain in the following section how a raw HTML file is broken into various files and how they are named, so that Drupal understands them and can parse them.

Getting ready

We are taking garland as the base theme for all the instructions in the following section (Drupal 7 is being used in all the instructions).

How to do it...

  1. Copy the folder of an existing Drupal theme (that is, garland) to sites\all\themes.

  2. Rename the copied theme folder to your theme. Let's suppose the new theme name is packt.

  3. Follow the directory structure of the old theme (garland) in the new theme (packt).

  4. Rename garland.info to packt.info and change the details such as the name and description in the file. The moment you complete this step, the theme will be reflected in the Admin panel. Rename the garland theme's variables as per the new theme.

  5. Navigate to Admin | Appearance. Your newly created theme should appear in the Disabled themes section.

  6. Enable the newly created theme (that is, packt) and check at the frontend.

  7. Start coding in the template files of the new theme as per your requirement and the provided HTML. Refer to the next section for more details.

    The following screenshot explains the file structure of the garland theme (all Drupal files will have files with the same name):

Once our theme is configured successfully in Drupal, it should appear in the Admin panel. Our theme, packt, is configured successfully as shown in the following screenshot: