1

This question is similar to this one How to make an attendance form, but i solved by entity refrence view widget module, saving date in a node, and having a field entityreference user relation with unlimited values. Now i have a views table of nodes like: enter image description here

and now i can not sum how many times a user entityreference appears, ofcourse at the bottom i need to have: John=3, Mary=2, Pete=2 I tryed views aggregartor plus with no luck, please make some suggestions how to achive this.

1

Solved. This is what I did. In order to not make heavy loads i enebleded Entity Construction Kit (eck) module, then by rules i added an entity (instead of a node) for every user entity reference value, within two columns, one for user name, and one for date in attendance. Now I can have a view (of entities) with two exposed filter on dates (beginning and ending dates) Then I override my views table tpl view with the following code. It displays a 2 column table, first: username, second: number of days that user has attendance. the following code assumes that username is second field on your view ($fieldloop == 2 ). code:

<?php $names = array(); ?>
<?php foreach ($rows as $row_count => $row): ?>
   <?php $fieldloop = 1; ?>
    <?php foreach ($row as $field => $content): ?>          
    <?php if ($fieldloop == 2 ) {$names[] = strip_tags($content);} ?> 
    <?php $fieldloop = $fieldloop + 1; ?>          
    <?php endforeach; ?>              
<?php endforeach; ?>

  <?php $attendances = (array_count_values($names)); ?>
<body>
<table>
<tr><th>Alumno</th><th># dias</th></tr>
<?php foreach ($attendances as $attendance => $value) : {
?><tr><td>  <?php print $attendance ; ?></td>
<td> <?php print $value; ?></td></tr>
<?php } endforeach; ?> 
</table>
</body>

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.