Drupal内容管理与视图定制全解析
1. 节点预处理与摘要显示
在Drupal开发中,我们可以通过自定义函数来处理节点的显示。以下是一个示例函数 bolg_preprocess_node :
function bolg_preprocess_node(&$variables) {
if ($variables['page'] === TRUE) {
// Reload the cached node to find the location of <!--break-->
$node = node_load($variables['nid']);
if (strpos($node->body, '<!--break-->') == 0) {
$variables['styled_summary'] = check_markup($node->teaser, $node->format, FALSE);
} else {
$variables['styled_summary'] = FALSE;
}// End of check for <!-- break -->
} // End of test for 'is this a page?'
} // End of function bolg_preprocess_node
在节点模板中,当查看完整页面时,可以使用变量 $styled_summa
超级会员免费看
订阅专栏 解锁全文
52

被折叠的 条评论
为什么被折叠?



