Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Transmitter on
Hello,
I've got one view which displays 5 fields in an "Unformatted list".
<div class="pic"><img src=""></div>
<div class="name">The Name</div>
<div class="date">The date</div>
<div class="category">The Category</div>
<div class="address">The Address</div>
how would it be possible to add a wrapper around name, date, category?
<div class="pic"><img src=""></div>
<div class="wrapper">
<div class="name">The Name</div>
<div class="date">The date</div>
<div class="category">The Category</div>
</div>
<div class="address">The Address</div>
Can I do this from within Views or do I need to update my views-view-fields.tpl.php?
And if with the views-view-fields.tpl.php - how?
<?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; ?>
With an if else?
Thanks,
Transmitter
Comments
you can use the moudle:https:
you can use the module:
https://drupal.org/project/views_php
drupal ,the sharp skill to eastablish website.
Using views
My suggestion would be to do everything from within views.
In your view you would hide the Name, Date and Category fields.
If you then add a Global Custom Text field you can add these fields wrapped in the html you require. I don't know your exact field names, but the Global Custom Text field would look something like:
Hope this helps
Ed
what is Global Custom Text
what is Global Custom Text field ?
drupal ,the sharp skill to eastablish website.
Views Fields
In your view, you can add fields.
When you click 'Add' in the Fields part of the view, one of the fields that you can select is called 'Global: Custom text'.
Having selected this field, you can customise it's output as required.
Cheers, Ed
Very good .. That's a way to
Very good .. That's a way to go I didn't think of. Thanks.
hi
hi
you can also follow this:
first hide from display two of the three fields then in the last field you can use "rewrite behavior" and put all the wrapper element with your fields in that using replacement tokens for respective fields.
I agree
I agree with prakharcse, their suggestion is even more concise.
Ed
Have to try that out - sounds
Have to try that out - sounds good as well. Thanks :)
I prefer a table template
I prefer to use the table display mode (this doesn't mean the output will be a table), and use a display template file such as:
views-view-table--"view-name"--"block-1".tpl.