So I have programmatically created a view mode and I need to theme it. The view mode will be rendered via views modules for different content types and The structure requires that I separate fields into to separate regions. A image region and content region. The different content types will be able to choose the fields they want for each region. So event may use featured image, while news article can use hero image field.

enter image description here

I really don't wan't to use display suite if there is some programmatic way of doing this.

  • use template files and create your own regions using divs – No Sssweat Apr 16 '16 at 1:21

You should be able to theme the fields behaving like a css-grid-system, maybe provided by your theme. Name view field templates like this:



  • Make sure they have the correct order in the view.
  • Empty fields wont be displayed.

If they have different names for the different content types, just include all field-names in your selectors ..

Maybe also have a look in the docs, and views have name suggestions under Advanced -> Theme: Click on Information

| improve this answer | |

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.