simone960's picture

I have created a views with 2 fields added, "title" and "body" fields, hide them and output via "Global: Custom text" field. And I am trying to group them so that they can output like this, e.g.:

<div>
 <div class="title"> title 1 </div>
 <div class="title"> title 2 </div>
 <div class="title"> title 3 </div>
</div>

<div>
 <div class="body"> body 1 </div>
 <div class="body"> body 2 </div>
 <div class="body"> body 3 </div>
</div>

However, no matter how I tweak, I couldn't find a way to do this and it always turn up like this, e.g.:

<div>
  <div class="title"> title 1 </div>
  <div class="body"> body 1 </div>
</div>

<div>
  <div class="title"> title 2 </div>
  <div class="body"> body 2 </div>
</div>

<div>
  <div class="title"> title 3 </div>
  <div class="body"> body 3 </div>
</div>

Any idea how this can be done in Views?

Accepted answer

Not sure what the best way to do this would be. I imagine that you might be able to do this with a custom template for the view.  

OR..... 

Create one view that just displays the title and another view that just displays the body. You can then add the body view to the title view as an attachment. 

(I am not sure if this is the best solution, but it should work).

Comments

Not sure what the best way to do this would be. I imagine that you might be able to do this with a custom template for the view.  

OR..... 

Create one view that just displays the title and another view that just displays the body. You can then add the body view to the title view as an attachment. 

(I am not sure if this is the best solution, but it should work).

simone960's picture

Create one view that just displays the title and another view that just displays the body. You can then add the body view to the title view as an attachment. 

Great thanks! Your solution works ! Surely there are other ways to do it and this is one of the best ! Thanks for the tips !

I agree with @stpaultim. Grouping fields in a single view will not give you want you want. Two views is better.