I want to render the rows of my “Recent content” Views page using a template in order to
- subdivide the rows into multiple divs,
- freely move around the rendered fields within these divs, and
- apply some custom PHP where needed.
Idea A (fails): I could achieve this by creating a new Display Suite layout for nodes and using this layout to render my view set to display format “Content”. However, I need to group the rows by a specific field, and grouping by fields is not available in the “Content” display format – for this, I would need to chose the display format “Fields”.
Idea B (fails): When displaying fields (say, as an unformatted list), I can make use a copy of
- views-view.tpl.php to adjust the coarse layout of the view, e.g., put an additional div around the whole content block;
- views-view-fields.tpl.php to adjust how a single field should be rendered;
- views-view-unformatted.tpl.php to adjust the coarse layout of rows, e.g. put an additional div around the whole row. However, here the $row variable is not an array of rendered fields but rather a string containing the full html markup of the row, so I cannot access single fields and move them around within the row as I wish.
Idea C (works, but isn't it extremely inefficient?): I could display an unformatted list of fields, but render only the Node-ID-field. Then, in views-view-unformatted.tpl.php I can load the whole node corresponding to the current row via $node = node_load($row); and access all fields attached to it via $node->field_whatever. These I can then move around as I wish, wrap in divs, and apply custom PHP.
Idea C seems to work, but it also seems highly inefficient, as I will have to load the full node for every row. Also, I want to leverage the many views display formatters that my fields come equipped with, which I would have to re-build manually.
Question: Is there a way to specify formats for specific fields within the Views UI, submit only these to a template (and not the whole node), and move them around freely within the row as explained above?