7 当用户位于drupal网站的首页时,如何只在模板中显示一个简单的首页检查? 我尝试了这个,但是最终崩溃了: <?php function drupal_is_front_page() {?> <h1>TEST</h1> <?php } ?> 使用drupal网站上的if代替此功能是否可行? 谢谢! 7 — 斯特凡 source
19 您不应在Drupal模板中声明函数。相反,您应该只引用该函数: <?php if (drupal_is_front_page()) { ?><h1>Test</h1><?php } ?> — 阿尔克斯·瓦列霍 source 4 注意,如果您的模板是page.tpl.php的派生类,则您已经具有$is_front可用的变量 — Clive
6 drupal_is_front_page() 返回布尔值。 <?php if(drupal_is_front_page()): ?> <h1>TEST</h1> <?php endif; ?> — 普拉文·阿贾兹(Pravin Ajaaz) source
$is_front
可用的变量