Sometimes we need to create some custom solutions one of them preseted below. In coments you can find some explanation and some notes.
{syntaxhighlighter brush: css;fontsize: 100; first-line: 1; }<?php /* * Implements of hook_block_info */ function taxonomy_menu_block_info() { // This example comes from node.module. $blocks['catalog_menu'] = array( 'info' => t('Catalog menu block'), 'cache' => DRUPAL_NO_CACHE ); $blocks['catalog_footer_menu'] = array( 'info' => t('Footer catalog menu block'), 'cache' => DRUPAL_NO_CACHE ); return $blocks; } /* * Implements of hook_block_view */ function taxonomy_menu_block_view($delta = '') { $block = array(); switch ($delta) { case 'catalog_menu': $block['subject'] = t('Taxonomy menu block'); $block['content'] = taxonomy_menu_catalog_menu('catalog'); break; case 'catalog_footer_menu': $block['subject'] = t('Footer taxonomy menu block'); $block['content'] = taxonomy_menu_footer_catalog_menu('catalog'); break; } return $block; } /** * @param (string) $vocabulary_name * @return array * renderable theme array */ function taxonomy_menu_catalog_menu() { $vid = 2; // intersesting note: //the last parameter equal to true is very important it allow us get taxonomy item as object where we can get image. $terms = taxonomy_get_tree($vid, 0, 1, true); $attributes = array( 'class' => 'taxonomy-custom-menu', ); return theme('item_list', array('items' => taxonomy_menu_tree($terms), 'attributes' => $attributes)); } /** * @param $terms * return of taxonomy_get_tree function * @param $brand * current brand value * @return array * renderable theme array */ function taxonomy_menu_tree($terms, $depth = 0) { $items = array(); $depth++; foreach ($terms as $term) { if (_term_do_print($term)) { if ($depth == 1) { $picture = field_view_field('taxonomy_term', $term, 'field_cat_image'); if(!empty($picture)){ $picture['#lable_display'] = 'hidden'; $picture[0]['#image_style'] = 'taxonomy_logo'; global $base_url; global $language; $url = "/taxonomy/term/" . $term->tid; $path = $base_url . '/' . $language->language . $url; $item_term_data = "<a href=" . $path . ">" . render($picture) . "</a>"; $items[$term->tid] = array( 'data' => "<div class='catalog-link'>" . $item_term_data . "</div>", 'class' => array('taxonomy_menu'=>'taxonomy_menu_top_item'), ); } } elseif($depth == 2) { $item_term_data = l(i18n_taxonomy_term_name($term), 'taxonomy/term/' . $term->tid); $items[$term->tid] = array( 'data' => "<div class='catalog-link'>" . $item_term_data . "</div>", ); } if ($children = taxonomy_get_children($term->tid)) { $items[$term->tid]['children'] = taxonomy_menu_tree($children, $depth); } } } return $items; } function _term_do_print($term) { if(_term_get_node_count($term) > 0 OR _term_child_have_nodes($term)) { return TRUE; } else { return FALSE; } } function _term_child_have_nodes($term) { $childs = taxonomy_get_children($term->tid); foreach ($childs AS $child) { if (_term_get_node_count($child) > 0 OR _term_child_have_nodes($child) > 0) return TRUE; } return FALSE; } function _term_get_node_count($term) { return db_query_range("SELECT COUNT(ti.nid) FROM {taxonomy_index} ti LEFT JOIN {node n} USING (nid) WHERE ti.tid = :tid AND n.status = 1", 0, 1, array(':tid' => $term->tid))->fetchField(); } /*Second block functions*/ /** * @param (string) $vocabulary_name * @return array * renderable theme array */ function taxonomy_menu_footer_catalog_menu() { $vid = 2; $terms = taxonomy_get_tree($vid, 0, 1, true); // TODO: cache per brand; $attributes = array( 'class' => 'taxonomy-custom-menu-footer', ); return theme('item_list', array('items' => taxonomy_menu_footer_tree($terms), 'attributes' => $attributes)); } function taxonomy_menu_footer_tree($terms, $depth = 0) { $items = array(); $depth++; foreach ($terms as $term) { if (_term_do_print($term)) { $item_term_data =l(i18n_taxonomy_term_name($term), 'taxonomy/term/' . $term->tid); $items[$term->tid] = array( 'data' => "<div class='catalog-footer-link'>" . $item_term_data . "</div>", ); if ($children = taxonomy_get_children($term->tid)) { $items[$term->tid]['children'] = taxonomy_menu_footer_tree($children, $depth); } } } return $items; }{/syntaxhighlighter}