Creating and Using Blocks

You have seen the basic components and features of blocks. The way to master their use is to actually start to use them.

Add a Navigation and User Login Block

The blocks that are available to you depend on your Drupal installation—particularly the contributed modules.

1. Open the block administration at Administer, Site Building, Blocks (D6: admin/build/block D7: admin/structure/block), as shown in Figure 19.3.

2. As you scroll down the page, you will see that most of the blocks are at the bottom in the section of disabled blocks shown in Figure 19.4. In both Figures 19.3 and 19.4, you can see labels identifying the regions of the page. You can drag blocks up and down. If you make any changes, you will see an asterisk next to the affected blocks. After you save the blocks, the asterisks will go away.

FIGURE 19.3

Open the block administration page.

Hie Week vittinu have 111 urfulnd i h* «il I put, location m ill. to. 111. 1 x h.inim h, 111»; ill lml", in, T . u nl i. nmwdng ow .lui' an ) uu not dit»

j pill h*nin tuiit HHwmbMf rhnr your I i.j«i minii dltfc rhp lull. ti 111 or rhu imki hi m rh p . ...

Odr the irvifliKrf ImO 'ill li: riv ' l»i> 11 in Vji r li m^ III

vblbUnv m: ii 'Imv.i: tUi wjt ■■■:■<« iluiinn (nil

3. Find the Navigation block and select the left sidebar for its location, as shown in Figure 19.5. Alternatively, you can drag it to the left sidebar section of the block list. (You drag to the section of the block list, not to the actual region of the page.) Click Save Blocks at the bottom of the page.

8l<*ki I STY Demo Site

FIGURE 19.4

Disabled blocks are at the bottom.

WlHj'i onto«' Active f«um isc« New forum toptcs" Recant B+bs Kstir een figure

n n

B&kllfTY ptnoSiu

Block

Operations

Content HudH

Powered by Dm pal

I tw

conflgura

Di*aM*d

+ User

een figure

■j. Navigation

)

configure

4- Sea nil form"

■ BE

eon figure

.]. Whc'tnw

I«—»

«onitgura

4- WlM}^ onto«'

!<•«>

M

configure

Active fwum lop»«

*

Configure

4- New forum toptcs'

van*-

m

configure

+ Recent B+sfl costs'

+

jStfSL

m

configure

4 MSR f«er.L pel

-m

configure ¡^j

Select the left sidebar for the Navigation block.

4. Configure the block by clicking the Configure button to open the page shown in Figure 19.6. The most important configuration is the title. Leave it blank for the default title (Navigation, in this case), enter <none> for no title, or enter your own title. You can also allow users to show or hide the block. In most cases, the default option (no user choice) is the best. If you are rearranging

blocks and configuring them, make sure that you save the rearrangement before you click the Configure button.

5. Configure visibility settings. Scroll down the page, as shown in Figure 19.7.

FIGURE 19.6

Configure the block.

jleiler

Administer

CdrtBnt management

&te «Hif"?jral«yi User management

'Navigation' bfock ar not they see this U

O 5*10" this >*** tv « O H Uta thü Maefe Of m

S how block for cp*clf)c rc

FIGURE 19.7

Configure visibility settings.

'Navigation' Bloc k 5J V Duro Li*

STY Demo Site jfeiler

M1 ttXOent

Coûtent nvaoagement Sie buiidrc«

Sceconftpjrar

'Navigation btock

Bietk ipMh wttlnji

Me a>«tftc wwiay setWBS P*q* specific urtialiiy Utting

S haw block an ip*elfle pa-goi:

H Shew or every page except His listed pi O Show on only (he luted pages, o Snow if the fcfltmtng PHP code returns :

The most common page visibility settings rely on roles. Some blocks should be seen only by logged-in (authenticated) users, and others only by not-logged-in (anonymous) users. If you have a webmaster or supervisor role, you may select some blocks to be shown only to those people. In some cases, Drupal blocks, such as Who's New, are appropriate for supervisors, but not for casual visitors, even authenticated users. As you place the blocks in their regions, just stack them together if you have role-based versions. Only one of them (if any) will appear, but it is a good idea for any variant of a given block to be shown in the same place.

6. List pages on which the block is shown or not shown. The most common such page is the front page (<f ront> is used in this entry field). This is the simplest answer to people who want a different front page. You also may use this section in conjunction with blocks containing menus. There is more on this in Hour 21. Save the block.

7. Using the same steps, add the Log In block to the left sidebar. If you follow this sequence, it will automatically be placed below the navigation block. Drag it so that it is above the navigation block, as shown in Figure 19.6. Click Save Blocks.

8. Click the Log Out button in the Navigation menu. You will see the User Login block and the abbreviated Navigation menu available to anonymous users, as shown in Figure 19.8.

FIGURE 19.8

user rogin

Log out to see the User Login block.

user rogin dHE)

RnqufS n** phxwqtiI

0 0

Post a comment