目前,当提交节点或评论时,会收到一封提交的文字,说明“由星期三,04/01/2015 - 18:07提交用户”
对此的加价是:
<span>Submitted by *user* on <time pubdate="pubdate" datetime="2015-04-01T18:07:34+0000">Wed, 04/01/2015 - 18:07</time></span>
我需要做的是从标记中删除“pubdate”属性,因为它在W3C验证时失败。
我曾尝试在template.php文件中添加以下代码,但没有运气
function ThemeName_preprocess_node(&$variables) {
$attributes['datetime'] = '<time'.drupal_attributes($attributes) .'>'.$variables['date'] . '</time>';
}
如何删除Submitted by标签中的“pubdate”属性?
答案 0 :(得分:0)
需要挂钩&#34; preprocess_node&#34;像这样访问$ submitted变量:
function THEME-NAME_preprocess_node(&$variables, $hook) {
$variables['pubdate'] = '<time datetime="' . format_date($variables['node']->created, 'custom', 'c') . '">' . $variables['date'] . '</time>';
$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' =>$variables['name'], '!datetime' => $variables['pubdate']));
}