Опубликовано 17 октября, 2015 - 23:26
<?php
/**
* Implements hook_block_info().
*/
function MYMODULE_block_info() {
$blocks['product_category_links'] = array(
'info' => 'Product category links',
'cache' => 'DRUPAL_CACHE_GLOBAL',
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function MYMODULE_block_view($delta = '') {
// The $delta parameter tells us which block is being requested.
if ($delta == 'product_category_links') {
$terms = taxonomy_get_tree(2, 0, 1, true);
$content = '';
$links = array();
foreach ($terms as $key => $term) {
$path = taxonomy_term_uri($term);
$links[] = l($term->name, $path['path']);
}
if (!empty($links)) {
$content .= theme('item_list', array('items' => $links));
}
$block['subject'] = t('Products');
$block['content'] = $content;
return $block;
}
}