0

I want to override the display of a field in a particular view, so that rather than printing:

<div class="field-content">Content here</div>

I just want:

<p>Content here</p>

Is this something which is best done in a template (I assume):

views-view-field--view-name--field-tagline.tpl.php

Edit: I've solved this using the above template, and then removing the wrapping elements from the view in via the Views UI. If using preprocessing is more performant, I'd still be interested to know, so please drop a line below if so. Otherwise, this question is solved.

1 Answer 1

2

I would suggest implementing the Semantic Views module. This allows you to easily customize the HTML that Views outputs for each level of elements (the entire view, row wrappers and field wrappers) from the UI. It is a bit easier to use and maintain than custom templates and preprocess functions.

5
  • Thanks for the heads up - I try to keep everything where possible in code and use version control for my development - ideally I'd be looking to keep this stuff in code too to ensure portability between sites and platforms. I'm not sure Semantic Views handles this?
    – jvc26
    Feb 12, 2012 at 16:38
  • Semantic Views is basically implemented as a Views display widget, so its settings can be exported with all other Views settings via the Views export.
    – sheena_d
    Feb 12, 2012 at 17:28
  • Ah ok - interesting. Unfortunately I'm using Views3 and D7, so I'll just keep to overriding the templates for the moment. Thanks for the heads up, will mark this as a potential answer.
    – jvc26
    Feb 12, 2012 at 18:30
  • Most of the features of Semantic Views are already integrated into Views 3. Going by your last edit on your question, it seems that you have found that functionality :)
    – sheena_d
    Feb 12, 2012 at 18:52
  • Yes indeed - thanks for the heads up - as I found out Views3 appears to incorporate much of what SV did, so thats a great step forward. Cheers for your help!
    – jvc26
    Feb 13, 2012 at 15:19

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.