2

How can I remove the Page SUM row in my Views Calc?

I have upgraded Views Calc module to its latest version.

1
  • 2
    After doing some trial and error, I have solved my problem. You can remove the Page SUM in the Views Calc table by using CSS. td.view-subfooter{ display: none; } – noob Apr 11 '14 at 7:18
2

You can achieve this in two ways

1) Add following style in your CSS

tr.view-subfooter-number{ display: none; }

OR

2) Go to views-calc-table.tpl.php file under views_calc module directory and find the following code (PAGE SUM row code)

  <tr class="view-subfooter-number">
    <?php foreach ($row as $field => $content): ?>
      <td class="view-subfooter views-field views-field-<?php print $fields[$field]; ?>  <?php print $options['info'][$field]['align'] ?>">
        <?php print $content; ?>
      </td>
    <?php endforeach; ?>
  </tr>

You can comment/remove the above code to hide 'PAGE SUM' row at view output.

1
  • 1
    2) if you are going to edit a .tpl.php, best to copy it to your theme folder first ! that way you are overriding it and you still have the original. – jowan sebastian Jan 4 '15 at 10:16
1

As the page sum is used with the pager, therefore it should really only appear when using a pager so:

copy the views-calc-table.tpl.php to your theme folder and edit the footer part to :

<tfoot>

<?php if ($view->query->pager->plugin_name != 'none' ): ?>

  <?php foreach ($sub_totals as $type => $row): ?>
    <tr class="view-subfooter-number">
      <?php foreach ($row as $field => $content): ?>
        <td class="view-subfooter views-field views-field-<?php print $fields[$field]; ?>  <?php print $options['info'][$field]['align'] ?>">
          <?php print $content; ?>
        </td>
      <?php endforeach; ?>
    </tr>
  <?php endforeach; ?>

<? endif; ?>

  <?php foreach ($totals as $type => $row): ?>
    <tr class="view-footer-number">
      <?php foreach ($row as $field => $content): ?>
        <td class="view-footer views-field views-field-<?php print $fields[$field]; ?>  <?php print $options['info'][$field]['align'] ?>">
          <?php print $content; ?>
        </td>
      <?php endforeach; ?>
    </tr>
  <?php endforeach; ?>

</tfoot>

the line if ($view->query->pager->plugin_name != 'none' ): means that it shows the page sum row only the views uses one of the pager plugins.

This way you are not relying on CSS and you can still use the page sum row when using a pager.

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.