-2

I have a view in drupal 7 but I cant show up the rows, I created a template for the row-style-output but nothing happen.

<?php

/**
 * @file
 * Default simple view template to all the fields as a row.
 *
 * - $view: The view in use.
 * - $fields: an array of $field objects. Each one contains:
 *   - $field->content: The output of the field.
 *   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
 *   - $field->class: The safe class id to use.
 *   - $field->handler: The Views field handler object controlling this field. Do not use
 *     var_export to dump this object, as it can't handle the recursion.
 *   - $field->inline: Whether or not the field should be inline.
 *   - $field->inline_html: either div or span based on the above flag.
 *   - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
 *   - $field->wrapper_suffix: The closing tag for the wrapper.
 *   - $field->separator: an optional separator that may appear before a field.
 *   - $field->label: The wrap label text to use.
 *   - $field->label_html: The full HTML of the label to use including
 *     configured element type.
 * - $row: The raw result object from the query, with all data it fetched.
 *
 * @ingroup views_templates
 */
?>
 
  <?php foreach ($fields as $id => $field): ?>
  <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
  <?php endif; ?>

  <?php print $field->wrapper_prefix; ?>
    <?php print $field->label_html; ?>
    <?php print $field->content; ?>
  <?php print $field->wrapper_suffix; ?>
<?php endforeach; ?>

enter image description here

enter image description here

2
  • What is the name of the template file? Where is the template file located in the codebase?
    – cilefen
    May 11 at 16:10
  • is located in themes->templates I can put html and I can see it but not the rows to show up the rows and using for example bootstrap to create a layout or something like that I will add a image in the post. May 11 at 17:05

1 Answer 1

0

According to your template name, it seems there is a mismatch between your template name and its content. You are using a template named views-view--blog-page.tpl.php but with the content of a views-view-fields.tpl.php file.

According to your Views template suggestions, here is how your templates shall be organised (from the most global one to the most accurate):

  • views-view--blog--page.tpl.php should override Views module views-view.tpl.php file. This is the global template of your View. In it, you can find $rows variable, which is the global result of your view. But you don't have access to each row details.
  • views-view-unformatted--blog--page.tpl.php should override views-view-unformatted.tpl.php. Here, you can alter your output at row level (e.g. Add a element around each row). Still no access to the details of each row.
  • views-view-fields--blog--page.tpl.php should override views-view-fields.tpl.php. It is the template used to output a row content (fields-level). This is the one to use if you wish to alter the output of your rows content.
  • views-view-field--blog--page.tpl.php should override views-view-field.tpl.php. Most accurate level. It is the output of each field inside each row.

Now, you just need to pick the Views template suiting your needs, override it with the right name and you should be fine. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.