1
如何將節目預告從node.tpl.php中的其餘內容中分離出來,以便將特技文本包裝在特殊標記中?Drupal:在全視圖中提取傳情
如何將節目預告從node.tpl.php中的其餘內容中分離出來,以便將特技文本包裝在特殊標記中?Drupal:在全視圖中提取傳情
您可以預處理主題變量以檢索預告並單獨存儲,否則Drupal會在內部處理它,並且不會給您一個選擇。
這裏是代碼:http://www.mydiary.digiprosoft.com/?p=244以下是該鏈接的亮點。
在的template.php
function phptemplate_preprocess_node(&$variables) {
// we like to display teasers on the node view pages in a different style,
// but only if they were NOT set to 「show summary on full view」 (which seems
// backward, but the implication with that checkbox is that the teaser is
// PART of the node’s body, instead of an actual summary of the entire
// node’s body). if a node’s unbuilt body starts with , then
// a teaser has been manually set, and 「show summary」 is not checked.
if ($variables['page'] == TRUE) { // only do this on full page views.
$node = node_load($variables['nid']); // we reload the node because
// by the time it gets here has already been filtered out.
// this if logic stolen from node.module’s node_teaser_include_verify().
if (strpos($node->body, '') === 0) {
$variables['style_teaser_differently'] = TRUE;
$variables['teaser'] = check_markup($node->teaser, $node->format, FALSE);
}
}
}
在node.tpl.php
<?php
if ($style_teaser_differently){
print '<div class="fullview-teaser">'.$teaser.'<div>';
}
?>
在檢查$ style_teaser_differently不起作用。但我可以禁用他們,因爲它的另一種內容類型與自定義node.tpl.php – dantz 2010-11-03 16:55:25