【发布时间】:2014-05-21 04:43:55
【问题描述】:
我的网站上有许多使用分类术语作为上下文过滤器的视图。我正在尝试将该分类术语添加到页面标题中。
即
'Latest TAXONOMY_TERM News | Sitename etc.'
我在我的 template.php 中的 THEME_views_post_render 函数中使用 taxonomy_term_load 来获取术语并构建页面标题。然后,我将此变量传递给 THEME_preprocess_html,并在其中使用它来覆盖 $variables['head_title']。
即
views_post_render:
$term = taxonomy_term_load($view->result[0]->_field_data['nid']['entity']->field_term['und'][0]['tid']);
$page_title = 'Latest ' . $term->name . ' News | ' . variable_get('site_name', 'Sitename etc');
preprocess_html:
$variables['head_title'] = $page_title ;
如果我回显 $variables['head_title'] 我可以看到我在 THEME_views_post_render 中定义的页面标题,但它显然缺少分类术语。
即
'Latest News | Sitename etc.'
任何人都可以对这里发生的事情有所了解吗?我确实考虑过在 THEME_preprocess_html 函数中执行所有逻辑,但这似乎无法访问视图。
感谢任何帮助。
罗伯。
【问题讨论】: