Drupal:ティーザーを完全に抽出します
-
28-09-2019 - |
質問
node.tpl.phpの残りのコンテンツからティーザーを分割して、ティーザーテキストを特別なマークアップでラップするにはどうすればよいですか?
解決
テーマ変数を前処理してティーザーを個別に保存することができます。そうしないと、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>';
}
?>
所属していません StackOverflow