我试图在每个标签打印为数组元素之前添加一些 html 代码。
我的代码:
$term_links = array();
foreach ($vars['node']->taxonomy as $term)
{
$term_links[] = l($term->name, 'taxonomy/term/' . $term->tid,
array(
'attributes' => array(
'title' => $term->description
)));
}
$vars['node_terms'] = implode(', ', $term_links);
目前,标签以逗号分隔打印。我想在每个标签元素之前添加一个小图像,img src="tag.png"
我该怎么做?
编辑 - 我当前的代码,仍然无法正常工作。
if (module_exists('taxonomy')) {
$img = 'some html';
$text = $img . $term->name;
$path = 'taxonomy/term/' . $term->tid;
$term_links = array();
foreach ($vars['node']->taxonomy as $term) {
$term_links[] = l($text, $path, array(
'html' => TRUE,
'attributes' => array(
'title' => $term->description
)));
}
$vars['node_terms'] = implode(', ', $term_links);
}
}