Drupal 7:在内容类型预告片上更改“阅读更多”

时间:2014-05-01 16:56:58

标签: drupal-7 teaser

在内容类型的预告片中,如何更改“阅读更多”链接按钮的文字?

1 个答案:

答案 0 :(得分:0)

通过将此代码放入主题的template.php文件中替换节点输出(使用您的主题名称替换为YourThemeNameYourContentTypeNewReadMoreText,并且需要阅读更多内容文本)。

<强> Source

<?php
// Preprocess variables for node.tpl.php.
function YourThemeName_preprocess_node(&$variables) {
  // Let's get that read more link out of the generated links variable!
  unset($variables['content']['links']['node']['#links']['node-readmore']);

  // Now let's put it back as it's own variable! So it's actually versatile!
  if ($variables['type'] == 'YourContentType') {
  $variables['newreadmore'] = t('<span class="YourContentTypereadmore"> <a href="!title">NewReadMoreText</a> </span>',
      array('!title' => $variables['node_url'],)
   );
  } else {
      $variables['newreadmore'] = t('<span class="newreadmore"> <a href="!title">Read More </a> </span>',
      array('!title' => $variables['node_url'],)
   );
  }

  $variables['title_attributes_array']['class'][] = 'node-title';
}
?>