在内容类型的预告片中,如何更改“阅读更多”链接按钮的文字?
答案 0 :(得分:0)
通过将此代码放入主题的template.php文件中替换节点输出(使用您的主题名称替换为YourThemeName
,YourContentType
和NewReadMoreText
,并且需要阅读更多内容文本)。
<强> 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';
}
?>