【问题标题】:Drupal - where is text "Submitted by" coming from?Drupal - 文本“提交者”来自哪里?
【发布时间】:2015-03-10 20:02:24
【问题描述】:

我的首页上有Views 插件显示的新闻。我发现视图项目(新闻)的模板​​在哪里。我用node--news.tpl.php 覆盖了它,我可以在其中更改新闻项目的html。但是有:

<?php if ($display_submitted): ?>
  <span class="submitted"><?php print $submitted; ?></span>
<?php endif; ?>

返回的代码:Submitted by Incredible on Tue, 03/10/2015 - 19:40

在内容设置中只是:

作者难以置信
作者2015-03-10 19:40:15 +0100

字符串 Submitted by 来自哪里,我该如何编辑它?

【问题讨论】:

    标签: php string templates drupal-7 drupal-views


    【解决方案1】:

    $submitted 变量设置在默认节点预处理函数template_preprocess_node()

    $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));
    

    您可以通过在主题的 template.php 文件中实现 hook_preprocess_HOOK() 来覆盖默认值,如下所示:

    function MYTHEME_preprocess_node(&$variables) {
      $variables['submitted'] = // Your username logic here.
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-22
      • 2010-09-26
      • 2010-09-21
      • 2017-04-24
      • 2023-03-28
      相关资源
      最近更新 更多