Drupal 7 içinde, taxonomy.pages.inc, sınıflandırma başlığı çıktısının etrafına bir <div class="term-listing-heading">
Yerleştiren taxonomy_term_page()
içerir.
Temamdaki taxonomy_term_page () çıktısını nasıl yeniden yazabilirim, böylece DIV'yi çekirdek hacklemeden kaldırabilirim?
taxonomy_term_page()
için kullanılabilir bir tpl.php dosyası olmadığından, bu temayı daha kolay hale getireceğinden oldukça şaşırdım.
Önişleme sayfasıyla böyle bir şey yapabilirsiniz:
function themename_preprocess_page(&$vars) {
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
unset($vars['page']['content']['system_main']['term_heading']['#prefix']);
unset($vars['page']['content']['system_main']['term_heading']['#suffix']);
}
}
temanızın template.php
İnanıyorum system_main
, site kurulumunuza bağlı olarak başka bir şey olarak adlandırılabilir.
Bir menü geri çağrısı olduğundan, o sayfa için çağrılan menü geri aramasını değiştirmek için bir modüle hook_menu_alter () uygulayabilirsiniz.
function mymodule_menu_alter(&$items) {
if (!empty($items['taxonomy/term/%taxonomy_term'])) {
$items['taxonomy/term/%taxonomy_term']['page callback'] = 'mymodule_term_page';
}
}
function mymodule_term_page($term) {
// Build breadcrumb based on the hierarchy of the term.
$current = (object) array(
'tid' => $term->tid,
);
$breadcrumb = array();
while ($parents = taxonomy_get_parents($current->tid)) {
$current = array_shift($parents);
$breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
}
$breadcrumb[] = l(t('Home'), NULL);
$breadcrumb = array_reverse($breadcrumb);
drupal_set_breadcrumb($breadcrumb);
drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
$build = array();
$build['term_heading'] = array(
'term' => taxonomy_term_view($term, 'full'),
);
if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
$nodes = node_load_multiple($nids);
$build += node_view_multiple($nodes);
$build['pager'] = array(
'#theme' => 'pager',
'#weight' => 5,
);
}
else {
$build['no_content'] = array(
'#prefix' => '<p>',
'#markup' => t('There is currently no content classified with this term.'),
'#suffix' => '</p>',
);
}
return $build;
}
Önceki örnek gibi, orijinal işlevi toptan kopyalamak yerine bir sarmalayıcıda taxonomy_term_page'in getirilerini değiştirmek daha temiz ve gelecekteki bir kanıt olabilir:
function mymodule_menu_alter(&$items) {
if (!empty($items['taxonomy/term/%taxonomy_term'])) {
$items['taxonomy/term/%taxonomy_term']['page callback'] = '_custom_taxonomy_term_page';
}
}
function _custom_taxonomy_term_page ( $term ) {
$build = taxonomy_term_page( $term );
// Make customizations then return
unset( $build['term_heading']['#prefix'] );
unset( $build['term_heading']['#suffix'] );
return $build;
}