0

I have a view that renders its contents as three fields, and based on the layout markup I received from our Front-end developer, two of these fields need to be wrapped in a container div so they can be floated as a column, with the first field and its encapsulating div serving as one column in itself.

However, I can't think of any way to theme these fields without creating a tpl.php, unless there's a prefix/suffix setting inside the Views setting i'm not seeing, and if not, what are my options for theming the field output?

The output generated is printed below.

<div class="item-list article-list">
  <li class="views-row views-row-3 views-row-odd clearfix">
    <!-- Row 1 (article img --> 
    <div class="views-field views-field-field-image">
      <div class="field-content">
        <div class="image-container image-only-box fl-lt">
          <a href="/node/129"><img typeof="foaf:Image" src=
          "placehold.it/100x100"
          width="100" height="100" alt="" /></a>
        </div>
      </div>
    </div>

    <!-- This would mark the beginning of Row 2 -->
    <div class="views-field views-field-field-article-type">
      <div class="field-content">
        <h3><a href="/taxonomy/term/18" typeof="skos:Concept" property=
        "rdfs:label skos:prefLabel" datatype="">Health</a></h3>
      </div>
    </div>

    <div class="views-field views-field-title">
      <span class="field-content"><a href="/node/129"></a></span>

      <p><span class="field-content">Donec consequat sem urna, quis posuere felis
      tincidunt sit amet ongue vestibulum</span></p>
    </div>
    <!-- End of Row 2 -->
  </li>
</ul>

3

Check this Post to learn about re-writing results in views

  • Add a new field called global:text in views and Choose Exclude from display in all the other fields you use

  • Now edit global:text and check rewrite result to add your mark-up there

enter image description here

0

You can combine fields by setting output none in the views field itself. Then in the field below it, switch rewriting on and combine the token values from both fields. If you want to assign a class, you can edit the wrappers for the field.

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.