Drupal Templating/Theming Resources or Advice?

2019-04-01 16:46发布

I'm interested in creating a custom theme for a Drupal site I'm working on. I am new to Drupal, however I have a decent bit of experience in working with the underlying concepts that it seems are needed to build a theme (CSS, PHP, HTML).
So, my question is - where do I start? Is there a canonical guide to creating Drupal themes? Resources that I should be aware of (other than the Theming Guide)? Gotchas that others have encountered, or just general words of wisdom from those who are more experienced?

6条回答
Juvenile、少年°
3楼-- · 2019-04-01 17:04

There is a learning curve, but I would recommend you start with the Zen Theme which has a theme starter kit included. Purchase the Drupal 6 Themes Book, Using Drupal Book and Front End Drupal and it should get you going in the right direction.

I've been learning it for almost 5 months now (coming from the Joomla world) and I have found it helpful to get to know the Drupal system by actually working with the examples from Using Drupal and the Front End Drupal Book. It really got me up to speed on how the system works, from installing modules, to configuring modules and setting up permissions and all the how to's for creating themes.

Learning how to setup a Drupal site is pertinent to building and deploying sites with Drupal as well as theming sites because the contributed modules as well as the core ones have to be over written with your own styles. Most people come into Drupal thinking that Drupal Themers are Designers but they are not. Most of them are programmers with little or no design experience and have someone else hand a pre-made design to them and then they take it integrate with Drupal. You will have to have, xhtml, css and some php experience to theme for Drupal. I hope this helps.

查看更多
可以哭但决不认输i
4楼-- · 2019-04-01 17:05

Can I recommend you install the DEVEL module http://drupal.org/project/devel

It can give you some really insightful clues how your page is being put together.

It also comes with a really useful feature called DRUAPL THEMER INFORMATION, which when activated lets you click on parts of your page, and tells you what bits of code did what.

My second tip is try and create your own node type templates, and then find out how the node data works.

For example in the theme folder create a new file called node-story.tpl.php

    <?php 
     print "<textarea cols=100 rows=30>". print_r($node,true) ."</textarea>";
# or krumo($node); # if you have krumo installed
     print "<h1>". $node->title ."</h1>";
    print "<p>" . formdat_date($node->created,"custom", "d/m/Y) ."</p>" ;



    ?>
查看更多
Viruses.
5楼-- · 2019-04-01 17:06

The best way to do it is to start with a theme, and modify it bit by bit. That's how most of the people whom I know do it. You take the themes/garland directory and copy it to sites/all/themes/garland-modified, then you change a few things in it to reflect the new change (in principle you rename the .info file to the new directory location and you edit it to change garland to your new directory), then you go bit by bit and change things in the files to reflect your design.

This may seem tedious and a waste of time (why not just start from scratch?) but you have several advantages:

  • you start with a working theme
  • you start with a complete theme, wich everything you may want
  • you don't risk of forgetting pieces which are required to have a working site

There are starter kits which are supposed to make things easier (see the zen theme for example) which you basically edit in a similar way I outlined above. But I found them a bit harder to understand...

Good luck with Drupal theming :)

查看更多
Melony?
6楼-- · 2019-04-01 17:10

zen as a starter theme and use the module that lets you mouseover your page and suggests page template names for those elements you want to theme. forgot the name of the module but it really kick started things for me. its not that straightforward otherwise. good luck

查看更多
闹够了就滚
7楼-- · 2019-04-01 17:14

Start with a starter theme and then build you own on top it. Here's a comparison table of different starter themes.

Update: There's also a starter theme review with screenshots, where the author explains them:

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.

查看更多
登录 后发表回答