Drupal string output

I am trying to create a page using view 2. This page lists all the nodes and groupings by their taxonomic term. In this view, the style as Unformatted and Row as fields. The fields are as follows:

Node: Title 
Node: Teaser 
Taxonomy: Term 

The problem is that I want the first line under each term to display Title and Teaser, and the rest to display only Title. Example:

-News

  • Headline and teaser
  • Title
  • Title

-Sport

  • Headline and teaser
  • Title
  • Title

-Entertainment

  • Headline and teaser
  • Title
  • Title

I tried to use a theme

  • view-view-unformatted.tpl.php
  • view-view-fields.tpl.php
  • view-view-field.tpl.php

over three files with no luck. I struggled with this issue for a while, any help would be appreciated. Thanks.

+3
source share
4 answers

" " (, views-view-fields.tpl.php).

, , , , . views-view-fields--myview--default.tpl.php.

, :

<?php 
  global $is_first_of_term;

  if(!isset($is_first_of_term)){
    $is_first_of_term = TRUE;
  } else {
    $is_first_of_term = FALSE;
  }


  // Then use $is_first_of_term below (unmodified original script)
  // to print whatever you want.
?>
<?php foreach ($fields as $id => $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
    <?php if ($field->label): ?>
      <label class="views-label-<?php print $field->class; ?>">
        <?php print $field->label; ?>:
      </label>
    <?php endif; ?>
      <?php
      // $field->element_type is either SPAN or DIV depending upon whether or not
      // the field is a 'block' element type or 'inline' element type.
      ?>
      <<?php print $field->element_type; ?> class="field-content"><?php print $field->content; ?></<?php print $field->element_type; ?>>
  </<?php print $field->inline_html;?>>
<?php endforeach; ?>
+4

" ". (panel3 module) , ( 1), - ( 2 3). "" .

; .

0

$id , 1. EX:

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
 <?php if (%id == 1): ?>
  <?php print [items you want] ?>
 <?php endif; ?>
  <div class="<?php print $classes[$id]; ?>">
    <?php print $row; ?>
  </div>
<?php endforeach; ?>

, , , , , , 15 . , .

0

Drupal Display Suite . , Display Suite, , , . , , , .

, PHP.

Check out the tutorial I found here: http://clikfocus.com/blog/changing-views-output-based-row for information on how to do this.

0
source

Source: https://habr.com/ru/post/1722324/


All Articles