4

我想要这个结果:

<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>',
    ),
  ),
);


提前致谢!

4

2 回答 2

2

只需将您的代码调整为:

$render = array(
  'link' => array(
    '#type' => 'link',
    '#title' => "<span>" . t("This is a link!") . "</span>",
    '#href' => "path/to/something",
     '#options' => array(
        'html' => TRUE,
    )
  ),
);

希望这行得通……穆罕默德。

于 2012-10-18T07:09:36.450 回答
0

对于#title 属性,只需像这样将跨度放入其中:'#title' => t("这是一个链接!里面有一个跨度!")

于 2012-10-18T01:41:46.983 回答