18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4<br />

Common theme hooks<br />

links<br />

Returns HTML for a list of links (cannot be nested).<br />

more_link Returns HTML for a more link, often used on blocks.<br />

pager<br />

Returns HTML for a pager query element, a list of pages for result sets<br />

too long for one page.<br />

progress_bar Returns HTML for an indicator showing a task's progress.<br />

table<br />

Returns HTML for a table.<br />

username Returns HTML for a username.<br />

user_list Returns HTML for a list of users.<br />

user_picture Returns HTML for a picture configured for the user's account.<br />

The theme hooks listed above are the most used hooks in <strong>Drupal</strong> core and also in<br />

<strong>Drupal</strong> contrib modules.<br />

<strong>Drupal</strong> blocks revisited<br />

So let's start building our single_blog module. We'll start with the .info file,<br />

of course. All of the lines in this .info file should be familiar to you:<br />

;$Id$<br />

name = Single blog<br />

description = Enables a single blog for an individual or multiple<br />

users.<br />

core = 7.x<br />

package = <strong>Drupal</strong> 7 <strong>Development</strong><br />

files[] = single_blog.module<br />

One of the things that the blog module provides is a block listing recent blog entries.<br />

We're going to use the Block API that was introduced in Chapter 2, Creating Your First<br />

<strong>Module</strong>, as we build a couple basic hooks and an API function for our new module:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!