Custom Blocks

strict warning: Only variables should be passed by reference in /home/newich/public_html/modules/book/book.module on line 560.

I'm not going to say a lot about custom blocks. But I will show you some really simple ones to give you a flavor. There's a lot I still don't know about custom blocks, and that fills many posts on the Drupal web site. One good starting point is: Blocks<.

Address

A business or support group should always let people know how to contact them. One easy thing is to include your mailing address on your pages. This is about the easiest kind of block to start with.

  1. Go to Administer>>Site building>>Blocks<. I should already be sitting on your default theme, but if not, select the right one.
  2. Click on the "Add block" tab.
  3. Fill in the "Description" and "Body." Here's a sample body:
  4. My company name<br>123 Main St.<br>Mytown, State Zip<br>USA<br>(123) 456-7890<
  5. Save the block.
  6. For some strange reason, you now need to "Configure" the block to add the block's name and placement.
  7. Add the name.
  8. Determine whether users can turn to block on or off. Then which roles can see it; leave this with no selections to allow everyone to see it. Then choose which pages it will be shown on; I show the address on all pages.
  9. Save the block.
  10. Now you're back on the block list. Locate the block you just created. Select its location; I like the address in the left sidebar. You can use the "Weight" parameter to set its position with in the selected area; again, I like the address at the bottom, so I use a heavier weight.
  11. Click on the "Save blocks" button.

That wasn't so bad was it?

Last Updated

It is fairly common practice, especially on a group site to let the visitors know when the site was last updated. This example requires you, the webmaster or administrator (sometimes called the "super user") to maintain the block. There are ways to automate it, but I leave that until we are all farther along in our Drupal education.

  • I followed pretty much the same process for the address block, giving this one a slightly heavier weight to sink it to the bottom.
  • <address>Feb. 12, 2007 - NEW</address><br>
    <small>Best viewed in a full window with Internet Explorer 5.5 or higher. Tested with IE6, Netscape 8, and Firefox 2.</small><
  • The main difference is that I wanted it only on the home (front) page. So under "Page specific visibility settings," I clicked on the "Show only on the listed pages" radio button, and entered <front>< in the pages box.

Okay, now you're an "expert" on blocks.