您可以通过preprocess_page(THEMENAME_preprocess_page(&$ vars)或MODULENAME_preprocess_page(&$ vars))的主题或模块实现来执行此操作,但上面的mac是正确的,因为在运行它们之前不知道它们是否为空,所以会有性能受到打击.
在该函数中,您应该可以访问结构化主链接数组,因此您可以运行视图:
$view = views_get_view('view_name');
// Swap out 'default' for a different display as needed. Also, $args are arguments, and can be left out if not applicable.
$output = $view->preview('default', $args);
if (empty($view->result)) {
// The view has no results, alter the primary links here to remove the link in question.
}
Run Code Online (Sandbox Code Playgroud)