Premade 2 cloumn Drupal layout.

Fma46 - July 15, 2008 - 07:00

Hello, I'm kinda of a newbie to Drupal, and I noticed the making a theme is really hard. I was wondering if someone could just make me a simple CSS layout.
http://nekonation.com/css/default.css
I made that CSS layout, and that is preferably what I would like to use.
To view my website on how I want it to look visit...
http://nekonation.com
Yes, i already have the site made, but it's not running drupal yet...

Easier than you may think

Keyz - August 27, 2008 - 04:36

Theming for Drupal is not actually as hard as you may think. Looking at a lot of the Drupal themes that you can download, it does look harder than it is, since those templates usually include tons of PHP "if this setting is true, then show this way, or else show that" sort of code, so that all kinds of situations and modules and configurations will work. However when you're making your own personal theme that's just for your own use, you don't need much or even any of that. All you need is the bits of PHP pasted into your own HTML template that load Drupal's dynamic content in those spots.

There are quite a few more that you could use if you want (here's a nice lesson with more details), but to drill down to just the most basic elements you need:

The head section of your site:

<head>
  <title><?php print $head_title; ?></title>
  <?php print $head; ?>
  <?php print $styles; ?>
  <?php print $scripts; ?>
</head>

Include the blocks that are set to show in the sidebar region/regions (see admin/build/block)... by default this includes things such as the login form and the admin menu. This is slightly different between Drupal 5 and 6...
Drupal 5:

<?php print $sidebar_left ?>

...and/or....

<?php print $sidebar_right ?>

Drupal 6:

<?php print $left ?>

...and/or....

<?php print $right ?>

Drupal's primary & secondary menu system (e.g. depending on the type of menu you're making, paste this into your template's sidebar area, or your top tab/button navigation... this outputs just a basic HTML unordered list, which you can style however you want)... if you are sure you're using the primary links and secondary links menus, then you can also remove the "if" and "endif" parts to make it look simpler):

<?php if ($primary_links): ?>
  <div id="primary">
    <?php print theme('links', $primary_links); ?>
  </div> <!-- /#primary -->
<?php endif; ?>

<?php if ($secondary_links): ?>
  <div id="secondary">
    <?php print theme('links', $secondary_links); ?>
  </div> <!-- /#secondary -->
<?php endif; ?>

Print out the main content + any appropriate help/messages, breadcrumb links, the title of each page, and sub-navigation tabs such as the View and Edit tabs... this goes in the center of your theme, where content usually goes (the "if" parts are since not all of these display on every page, some such as $messages only when appropriate):

<?php if ($breadcrumb or $title or $tabs or $help or $messages): ?>
  <?php print $breadcrumb ?>
  <h1 class="title"><?php print $title ?></h1>
  <div class="tabs"><?php print $tabs ?></div>
  <?php print $help ?>
  <?php print $messages ?>
<?php endif; ?>

<?php print $content; ?>

Must go at the end of your page.tpl.php file:

<?php print $closure ?>
</body>
</html>

Lastly, in Drupal 6, the one final element is to create a YourThemeName.info file:

name = YourThemeName
description = Description of YourTheme
core = 6.x
engine = phptemplate
stylesheets[all][] = style.css

I hope this is helpful for you :) Paste in the above bits of code into ANY site layout, and you have a Drupal theme.

-- David
absolutecross.com

David, this is great stuff

Jeff Burnz - August 29, 2008 - 03:05

David, this is great stuff for newbies, if not already perhaps you could expand this into a helpful book page in the docs?

Absolutely

Keyz - August 29, 2008 - 04:52

Absolutely :) I'll copy this over to my site to perfect it and post it to the handbook within a few days. I "ate my dog food" on this the other day, and converted the theme for my site absolutecross.com into a Drupal theme literally within a few minutes. It wouldn't be "contrib ready" in that time, but for a personal theme not meant for contrib it's a piece-o-cake :) I'm sure there will be a few spots theming more inticate bits of it, but this gets ya most of the way there.

-- David
absolutecross.com
[new guide/lesson in progress: Creating a CCK and Views powered Drupal site - feedback welcome]

About half done

Keyz - August 29, 2008 - 09:24

Got a good start on it... about half done with my "rewrite": http://www.davidnewkerk.com/book/33

-- David
absolutecross.com
[new guide/lesson in progress: Creating a CCK and Views powered Drupal site - feedback welcome]

 
 

Drupal is a registered trademark of Dries Buytaert.