Hi

I've changed the layout of the table in views-view-table--tracker.tpl.php however I now have a problem. The table seems to duplicate itself horizontally (almost like its adding colspan): Please have a look: www.allbuyart.com/tracker, I only want the first column. I can't figure out why its happening, the only view code i've changed is in the views-view-table--tracker.tpl.php:

  <tbody>
    <?php foreach ($rows as $count => $row): ?>
      <tr class="<?php print implode(' ', $row_classes[$count]); ?>">
        <?php foreach ($row as $field => $content): ?>
          <td class="views-field views-field-<?php print $fields[$field]; ?>">
            <?php print $row['field_image_fid']; ?>
          </td>
          <td>
<table>
<tr>
<td>
<?php print $row['title']; ?>
</td>
</tr>
<tr>
<td>
<?php print $row['teaser']; ?>
</td>
</tr>
</table>
    </td>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>

Why is this happening?

cheers

Mike

Comments

pbarnett’s picture

That looks a real mess; you have an entire table definition

<table>
<tr>
<td>
<?php print $row['title']; ?>
</td>
</tr>
<tr>
<td>
<?php print $row['teaser']; ?>
</td>
</tr>

inside the two nested $rows and $row loops.

What were you actually trying to do?

I'd put the template file back the way it was and start again!

nevets’s picture

Are you aware that you can directly combine fields in the table using the views UI (click the gear next to style: table).

Though I have to wonder, why use a table if you only want one column?

phatmike10’s picture

Thanks Nevet, using the UI worked!

If I wanted to actually change the code of the view theme so I had my thumbnail in the left column then in the right column had title then teaser below the title. How would I go about doing that?

nevets’s picture

I would use the display suite module, add a build mode, make a layout that shows the thumbnail, title and teaser as described for content type(s) as needed. Then set the view to use display suite and new build mode.

phatmike10’s picture

Thanks, I've just tried the Display Suite but I think i'd prefer to actually get into the views template. I've changed views UI so all fileds are in 1 column. I've also changed the views-view-table--tracker.tpl.php so it has 2 columns, the problem i've got is the fields are duplicating for both columns row by row e.g. www.allbuyart.com/tracker here's the code i've changed:

  <tbody>
    <?php foreach ($rows as $count => $row): ?>
      <tr class="<?php print implode(' ', $row_classes[$count]); ?>">
        <?php foreach ($row as $field => $content): ?>
          <td class="views-field views-field-<?php print $fields[$field]; ?>">
		<?php print $row['field_image_fid']; ?>
                <?php print $row['title']; ?>
		<?php print $row['teaser']; ?>
          </td>
          <td class="views-field views-field-<?php print $fields[$field]; ?>">
		<?php print $row['field_image_fid']; ?>
                <?php print $row['title']; ?>
		<?php print $row['teaser']; ?>
          </td>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>

How stop it duplicating the content in both columns and instead display unique content in each column?

cheers

Mike