我想要这个结果:
<a href="path/to/something">This is a link! <span>with a span inside!</span></a>
这会呈现一个链接:
$render = array(
'link' => array(
'#type' => 'link',
'#title' => t("This is a link!"),
'#href' => "path/to/something",
),
);
为什么这不会在链接中呈现跨度?
$render = array(
'link' => array(
'#type' => 'link',
'#title' => t("This is a link!"),
'#href' => "path/to/something",
'span' => array(
'#type' => 'markup',
'#markup' => ' <span>with a span inside!</span>',
),
),
);
提前致谢!
最佳答案 只需将您的代码调整为:
$render = array(
'link' => array(
'#type' => 'link',
'#title' => "<span>" . t("This is a link!") . "</span>",
'#href' => "path/to/something",
'#options' => array(
'html' => TRUE,
)
),
);
希望这有效……穆罕默德.