【问题标题】:PHP - Bolding certain text within tPHP - 在t内加粗某些文本
【发布时间】:2018-05-08 15:32:48
【问题描述】:
$need_it_sooner = l(
    t('Need it sooner? Click here'), 
    'need-it-sooner', array(
    'attributes' => array(
            'class' => array('float-right', 'button', 'button-red'),
            'style' => 'float:right;',
        ))
    );

这是我的代码,我希望它显示出来

需要吗?点击这里。

我能否在 t() 中轻松地设置文本样式,还是必须编写另一个大块来完成此操作?

【问题讨论】:

  • 可能将font-weight: bold; 添加到'style' 属性中?
  • 你能把lt的源代码贴出来吗?!
  • 你在使用 Drupal 吗?
  • 我认为你应该在你的问题中指出这一点。 lt 是 Drupal 函数,而不仅仅是 PHP 函数。

标签: php html css drupal


【解决方案1】:

在 Drupal 7 中,函数l 将一组选项作为第三个参数。如果您将选项 'html' => TRUE 传递给它,它可以接受 HTML。 您也可以通过函数t 传递HTML。所以你可以尝试这样做:

$need_it_sooner = l(
    t('<strong>Need it sooner?</strong> Click here'), 
    'need-it-sooner', array(
    'attributes' => array(
            'class' => array('float-right', 'button', 'button-red'),
            'style' => 'float:right;',
        ),
    'html' => TRUE)
    );

【讨论】:

    【解决方案2】:

    建议使用l() 函数,但如果您有特定要求,请考虑其他选项。即

    $need_it_sooner = '<a href="'.url('need-it-sooner').'" ><strong>'.t('Need it sooner?').'</strong> '.t('Click here').'</a>';
    

    从我的脑海中编写此代码,因此可能会出现一些错误,但这就是想法。使用 2 个 t() 调用分别翻译文本。如果可以,请避免嵌入 css。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多