【发布时间】:2016-01-10 20:08:10
【问题描述】:
在我的 Drupal 7 站点中,我使用打印机、电子邮件和 PDF 版本模块。我想在特定内容类型的某些特定页面上显示打印机链接。所以我启用了该内容类型的链接,其中包括一个布尔字段(field_printable),管理员应该能够选择是否包含链接。 在我的 template.php 文件中,我试图弄清楚如何解决这个问题。这是我目前在我的 template.php 文件中得到的:
function mytheme_preprocess_node(&$variables) {
if($variables['type'] == "mycontenttype"){
// boolean field that returns 1 if checked
if($node->field_printable['und'][0]['value'] == 1){
what to put here ...?
}
}
}
我可能应该使用 print_insert_link();插入链接,但我不知道如何。谁能指出我正确的方向?我花了几个小时在谷歌上搜索类似的问题,但我现在卡住了。
任何帮助将不胜感激,在此先感谢。
已编辑:我尝试此操作后屏幕变为空白...
function mytheme_preprocess_node(&$variables) {
if($node->nid == 408){
$variables['print_custom_link'] = print_insert_link();
}
}
我还在我的节点模板文件中添加了这个:
print render($content);
if(!empty($print_custom_link)){
print render($print_custom_link);
}
【问题讨论】: