Help Creating Theme

gibby - December 19, 2002 - 04:22

Hi, all,

I am new to Drupal, and must say that I'm very impressed with the design and the obvious amount of brainpower that went into this.

I'm trying to create a theme, but there isn't enough documentation on how to do this.

The docs point me to the existing themes to see how they were written. While I understand the PHP just fine, the context in which it is running is completely missing for me, since I know nothing about drupal.

Examples:
* When does the node() function get called?
* I can see in the resulting browser code (using the Marvin) theme that 2 columns have been defined. It's not at all obvious to me how that is controlled from within the .theme file...

I have many other questions as well; but I assume I've missed a reference guide somewhere. I've read the Themes section of the Handbook and the Themes Developers Guide pages.

Can anybody help out a Drupal newb?
Thanks,
Gibby

Columns

kyvinh@hcilib.s... - December 19, 2002 - 15:48

Basically, the colums are defined in header and footer. At the end of the header function, you will see the beginning of a '<td>' statement. That's where marvin's first column begin. The content of that column is then generated by Drupal. Then to end that first column, the footer function begins with a '</td>' statement. The second column begins right away and contains 'theme_blocks("all", $this);' which displays the content of the second column (the blocks).
To summarize, when generating a page, Drupal calls 'header', generates the content of the page, then ultimately calls 'footer'. It's all logical, somehow.
As for node(), it is called whenever a node has to be generated. Whether it is on the front page or on an individual page. The $node argument contains all the information about the content to be generated.
Does it help?

addendum

ax - December 20, 2002 - 09:57

The second column begins right away and contains 'theme_blocks("all", $this);' which displays the content of the second column (the blocks).

addendum: you can have 3 columns if you add another table column (&lt;td&gt;&lt;/td&gt;) and, instead of theme_blocks("all", $this), call theme_blocks("left", $this) for the left and theme_blocks("right", $this) for the right column. note that there has been discussion about supporting more that just 2, actually
arbitrary blocks regions - see this (footnote 1) for more.

Thanks, ax, for the reply.

gibby - December 20, 2002 - 17:56

Thanks, ax, for the reply.

If I understand the bottom of that link correctly, in the 3-column case, the middle column's region is "all"? Am I correct in assuming that "all" doesn't mean "all" in that the "left" and "right" regions are specifically excluded?

The aim first comment in that thread makes sense to me. I do want to render boxes in the main area of my side differently than I do in the sidebars. The discussion of boxes vs blocks is thoroughly confusing, though... Can you help me by clarifying for me:

What is a box?

What is a block?

Thanks for your help,
Gibby

Thank you for the reply, kyvi

gibby - December 20, 2002 - 17:47

Thank you for the reply, kyvinh.

While I understand the mechanism for the engine calling user-defined functions like header() and footer() to abstract the page, your reply really helps me understand that the "control" of where boxes are rendered doesn't really exist (hence my confusion).

Now that you've told me that 'theme_blocks()' is for, I understand what is going on, thank you.

More questions, if you (or anyone else) feels up to it?

where did theme_blocks() come from? is there a list of theme functions? (the theme functions page doesn't seem to list it.) A place in the source to go to see what's available?

term definitions:

I'd like to know how the following differ from one another. When the documentation uses these terms its almost always assumed that these terms are already understood, or a circular definition is provided

* what's a node? "nodes are a conceptual "black box" to couple and manage different types of content..."
* what's a block? "Blocks are the boxes visible in the side bars on the left- and right-hand side of the website.... Example: Only show on node pages..."

?? I'm confused. What's a node page? Isn't every page a node? Is the box() function in a theme what is called when a "block" is to be rendered? If everything is a node, how come the node() function isn't called when I set my new site to marvin theme and view the source? HELLP

Sorry for so many questions; but hopefully you can see the nature of my problem. I'm going to keep plugging away at it, because I'm convinced once I get through the introductory learning wall--er, curve, Drupal will ultimately be able to do for me what I'm looking for.

Thanks in advance for your help
Gibby

More...

kyvinh@hcilib.s... - December 21, 2002 - 15:57

Alright, let's get organized...
Your node() will be called. Just create a new blog for example, then go to your blogs page and you will see your node...
The marvin theme should have all the functions you need to create your theme, so just dig in there and you'll have what you need.
Organizing your questions might help, because I don't know where to start

Questions

Anonymous - December 21, 2002 - 19:33

Exactly my problem-- where do I start? It's difficult to organize questions about a topic until one knows at least a little something about it. As I mentioned earlier, the documentation on drupal I'm reading assumes I already know the definition of the terms being used, yet I can find no place where they are defined

Maybe we could start there? How about definitions of the following 'drupal' terms, and an explanation of how they differ from each other?

* module, node
* block, box
* story, book
* site page, story, article

Not fully understanding these terms and their differences is preventing me (and I imagine, others) from being able to take advantage of what documentation there is.

Thanks for your help,
Gibby

Drupal Terminology

adam@csof.net - December 22, 2002 - 00:53

(If deemed appropriate could someone proofread this and add it to the documentation? -- Adam.)

As you start to read the Drupal documentation and learn how it works it will help a lot if you know what a few words mean.

General Terms

Module
A module is a piece of code which extends Drupal to provide a specific piece of functionality. Some modules are part of the core Drupal system (eg. the taxonomy and blog modules) and some others live in the contributions CVS repository and need to be downloaded from there.
Theme
Themes are used to change the way Drupal looks. They are normally a mixture of PHP code and HTML. While a little familiarity programming PHP will help even beginner programmers should be able to customize one of the default look and feel quite easily. There are additional themes also available in the contributions CVS repository.
Node
Nodes are probably the hardest Drupal concept to grasp but they are really quite simple. Almost all content in Drupal is stored as a node. When people refer to "a node" all they mean is a piece of content within Drupal, it could be a poll, a story, a book page an image etc.
Block
Blocks are what are sometimes called "Slash Boxes". They are the navigational or content additions that live on the left or right side of a page when you view it in your browser. Blocks are not nodes, they are just a wayu of positioning data within a page.
Box
I believe boxes are an outdated piece of terminology. They don't exist anymore.
Taxonomy
Taxonomy is literally "the science of classification". Drupal uses taxonomy to describe the category system, which you can use to classify and organize content on your web site.

Node Types

Site or Static Page
Site pages are static pages which are typically (but not required to be) linked into the main navigation bar. One special thing about them is that they can contain customized PHP code in order to make their content dynamic.
Story Page
Stories are the generic page type that most content management systems have. Stores are generally used for information which is only relevant for a period of time (eg. news stories) and is expected to expire off of the page.
Book Page
Book pages are designed to be part of a collaborative book. An example of a collaborative book is the Drupal developer documentation . Originally only book pages could be a part of a book but these days all node types can be part of a book. Really the only special part about book pages these days is that like static pages they can contain PHP code.
Poll
A poll is where a multiple choice question is asked and users can answer and see other peoples answers to questions.
Blog
Blogs, or weblogs, are another term for an online journal or diary. They are a place where members of the community can write their own thoughts and not have to worry about being ontopic for the site.
Forum
Forums are the same thing as online bulletin boards. New forums can only be created by administrators of the site and are generally dedicated to a particular topic or queestion. Once a forum is created anyone can ask questions or comment on other peoples questions.
Comment
Comments actually aren't nodes, they are their own special content type. Comments are what allow people to add comments to any other node that has been created.

Wow

gibby - December 22, 2002 - 20:37

Thank you so much, Adam

Just re-reading some of the documentation after reading your definitions has lifted 2/3 of the fog

I mean it--I've managed to get my theme mostly running, and I've almost completed writing a new module (now that I know what one is ) to set my site's home page up just the way I like it.

All that stands between me and a working initial site is a question about security (allowing some users to see some content and others not); but I'll ask that in the appropriate forum.

Really, a big thank you.
Gibby

Good work Adam

akaash19 - April 4, 2008 - 07:40

Nice explanation. appreciable effort. Keep going ..

 
 

Drupal is a registered trademark of Dries Buytaert.