Community & Support

views module. How to wrap fields in one single div ?

Hello

I am looking for a way to wrap two different fields in one single div. Actually I have 3 fields such as this :

  • <div class="views-field-title">
  • <div class="views-field-body">
  • <div class="views-field-field-image-slide-fid">

I would it to look like that :

  • <div id = "paging">
    • <div class="views-field-title">
    • <div class="views-field-body">
  • </div>
  • <div class="views-field-field-image-slide-fid">

Any ideas ? I tried to overide several template files form the theme:informations. But I cannot acces each field individually. Even I have $content (an array with all the fields) otherwise, there is the "field output" template files that deals each field separately by spitting it out throught the variable $output...

so I am a bit in a trouble here. If anyone has already done this before, it would help me a lot

Michael

Comments

I get into the same problem

I get into the same problem again :(

No idea ?

You can rewrite the output of

You can rewrite the output of one of your first 2 fields to include a token for field1 and field2. Then you can wrap them in a div.
Add html to your rewrite like this...

<div class="your-class-name">
<br>[field1]</br>
<br>[field2]</br>
</div>

Your actual token list (replacement patterns) will appear in the field settings once you click on "rewrite the output of this field".
Make sure that whichever field you are rewriting appears in the field list below all of the fields you want to use.

Then exclude from display all of the other fields.
In the example above, my list would say
field1 (excluded)
field2 (rewritten)

You can also exclude field 2 and use it as a "group by" in an HTML list view style.

Thank you for that! Now I can

Thank you for that! Now I can finally make a background around some Views-div without gaps between them :D.

I love you

@Broberg

I was ready to make a new up today as I got stucked once again into the same problem. And obviously I wasn't the only one ;)
The solution was just very easy. That's the thing with Drupal. Every thing is there and very simple to use. But the problem here is about common sens ! I should had thought about it.

I really appreciate your help. Thank you again.

Excellent

Stupid I've never thought about that ;)
Thanks!

Thanks a lot for the tip

Thanks a lot for the tip

Andrei

Awesome!

This is a great quickie way to do it. Just out of curiosity, are there any other easy ways to do this? Seems a bit hacky.

Nice !

Thanks ! It works well but i agree with rootdownmedia, it seems a bit hacky.
Is there any other clean way to do it ? (without using a template file)

Semantic Views module is what

Semantic Views module is what you are looking for. You can customize html output for each field from within the views interface.

Great Info

Just what i was looking for. Thanks