Score:-2

How to create a custom layout with for a view, I have tried to print the fields but nothing works I created the template but cant display rows

ar flag

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

id flag
What is the name of the template file? Where is the template file located in the codebase?
ar flag
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.
Score:0
de flag

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. :-)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.