当前提交节点或注释时,会收到一条submitted文本,上面写着"submitted byuseron Wed,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"属性?
需要挂接到"preprocess_node"以访问$submit变量,如:
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']));
}