Drupal Views 2: custom markup output

I have a simple view that captures 4 fields, basically it captures the fields of a certain type of content. The fields are as follows:
CSS class (plain text)
Image (image)
Name
Body

Pretty simple stuff. I have a view, but I need to output the data in a specialized way, and I can’t determine how this material breaks down in conjunction with my custom markup from my assembly. I need to wrap each line in a container, and each line is broken into its own containers, look at the following code.

   <div id="homepage-folio-portlets">
    <div class="homepage-folio-portlet [CSS class]">
     <div class="homepage-folio-portlet-image"><img src="[Image]" width="450" height="330" alt="" class="[CSS class]-image" /></div>
     <div class="homepage-folio-portlet-text">
      <strong>[Title]</strong>
      <p>[Body]</p>
     </div>
    </div> <!-- /homepage-folio-portlet -->
   </div> <!-- /homepage-folio-portlets -->

, , --, , , -folio-portlet , CSS .

- , .tpl , template.php. , , . , template.php, , CSS , . .

+3
3

, , . "-" , " " - foreach. , , . , $['ID-of-field'] → content. "ID-of-field", " ", " " " " " " .

" ", , .tpl " " , view-view-fields - my-view -name -. default.tpl.php

view-view-fields - my-view-name - default.tpl.php - .tpl file

( foreach, , , , , , )

   <div id="homepage-folio-portlets">
    <div class="homepage-folio-portlet <?php print $fields['CSS_class']->content ?>">
     <div class="homepage-folio-portlet-image"><img src="<?php print $fields['Image']->content ?>" width="450" height="330" alt="" class="<?php print $fields['CSS_class']->content ?>-image" /></div>
     <div class="homepage-folio-portlet-text">
      <strong><?php print $fields['Title']->content ?></strong>
      <p><?php print $fields['Body']->content ?></p>
     </div>
    </div> <!-- /homepage-folio-portlet -->
   </div> <!-- /homepage-folio-portlets -->

"Output Style" "Display output".tpl, Drupal. , , , $row ( foreach loop) .tpl $rows tpl. , , . , . , .

...

views-view-unformatted - my-view-name - default.tpl.php - .tpl
( foreach , )

<?php foreach ($rows as $id => $row): ?>
 <?php print $row; ?>
<?php endforeach; ?>

views-view - my-view-name - default.tpl.php - .tpl

<?php print $rows; ?>

, , , admin .., .

+3

"" " " ":" "". " : Theming" , . - "", , .

, , , "Row style":

  • " ", .
  • , , , , , , ..
  • , # 1, , # 2
  • ,
  • " ",
  • 1-5 , .
+1

? views ( ). "" , . ( ).

0

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


All Articles