0

I have a view block, where fields are added in the table. I followed below steps to customize the output fields:

  1. Navigate to the edit screen for a view (for example, admin/structure/views/view/MYVIEWNAME/edit).
  2. In the Fields section, click a field. The Configure Field dialog box displays.
  3. Click Style Settings.
  4. Enabled the following options: Customize Field HTML

  5. Specified the HTML element <div> to wrap around the item. and clicked on Create a CSS Class and specified a class name.

  6. disabled the Add Default Classes option.

  7. Clicked on Apply.

    The problem is, the specified class name in step no. 5. got added to the corresponding <td> of the view table and not to the selected html element <div>

    How to add class name for the specified HTML element <div> ?

  • I still don't get the question, so you added a div class of "example" in step 5. So what's the problem? – No Sssweat Dec 2 '15 at 9:25
  • I want <td> <div class="test">fieldname</div> </td> for the view field, so i selected HTML element <div> and specified class name 'test' . But once i save and output is <td class="test"> <div>fieldname</div> </td> – rks Dec 2 '15 at 9:46
1

For this case, don't use Style Settings. Instead, use Rewrite results.

Click on Replacement patterns, to get the Token of your field.

Then just wrap Token inside div tag.

enter image description here

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.