Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Apress.Pro.Drupal.7.Development.3rd.Edition.Dec.2010.pdf
Скачиваний:
73
Добавлен:
14.03.2016
Размер:
12.64 Mб
Скачать

CHAPTER 10 WORKING WITH BLOCKS

return array('#markup' => theme('item_list', array('items' => $items)));

}

break;

}

}

The result of your new unpublished nodes block is shown in Figure 10-7.

Figure 10-7. A block listing unpublished nodes

Enabling a Block When a Module Is Installed

In the approval module, we automatically enabled the blocks and assigned them to a region of the theme. For example, I created the Pending Comments block and automatically enabled it (status = TRUE) and assigned it to the sidebar_first region.

$blocks['pending_comments'] = array(

'info'

=> t('Pending Comments'),

'status'

=> TRUE,

'region'

=> 'sidebar_first',

'weight'

=> 0,

);

 

In some cases, you may want to allow a site administrator to determine whether the blocks should be enabled and which region they are assigned to in the theme. In that case, set the status attribute to FALSE and do not assign a region to the block. The following example demonstrates creating a new Pending Users block that is not automatically enabled and is not assigned to a region.

$blocks['pending_users'] = array(

'info'

=> t('Pending Users'),

'status'

=> FALSE,

'weight'

=> 0,

);

 

237

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]