【问题标题】:Drupal 7: displaying array variables with its links in node.tpl.phpDrupal 7:在 node.tpl.php 中显示数组变量及其链接
【发布时间】:2011-03-23 10:48:54
【问题描述】:

我正在使用 Drupal 7 构建一个单用户博客。我使用文章内容类型作为博客条目。我需要自定义节点的外观。我还在文章引用类别中添加了一个分类字段。我需要在我的节点中的特定位置显示这个和标签。

所以,我写了代码 dpm(get_defined_vars()); 并获取变量(如下所示)

但是如何在我的 node--article.tpl.php 中显示这些变量,并带有指向页面列表的链接,其他文章条目具有这些标签、类别?这些是数组,我需要用链接显示每个数组项:/

感谢帮助!!!!非常感谢!

【问题讨论】:

    标签: php arrays drupal drupal-7 drupal-theming


    【解决方案1】:

    不知何故

    <?php
      $links = array();
      foreach ($node->field_tags AS $term) {
        $links[] = l($term['taxonomy_term']->name, 'taxonomy/term/'. $term['tid']);
      }
      print implode(', ', $links) .'<br />';
    
      $links = array();
      foreach ($node->field_blog_post_category['und'] AS $term) {
        $links[] = l($term['taxonomy_term']->name, 'taxonomy/term/'. $term['tid']);
      }
      print implode(', ', $links);
    ?>
    

    【讨论】:

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