I have a clonable template with a custom field called status that takes in two params..satisfied and notsosatisfied and I want to display monthly stats in % of how many are satisfied and how many are notsosatisfied out of all from that month.
This is my code for displaying the archives:
Listing code:
The thing is that when testing with this scenario:
5 pages added in 01.2018
1 page added in 01.2017
This is ok: When I press on January 2018 (5) I get Satisfied: 80% Not so satisfied: 20% Total: 5
But when I press on January 2017 (1) i get the stats for all 6 pages: Satisfied: 67% Not so satisfied: 33% Total: 6
..when it should have been Satisfied: 0% Not so satisfied: 100% Total: 1
Where am I going wrong with this?
This is my code for displaying the archives:
- Code: Select all
<cms:archives masterpage='feedback.php' type='monthly'>
<li>
<a href="<cms:add_querystring "<cms:link 'stats.php' />" "start_on=<cms:date k_archive_date format='Ym'/>" />"><cms:date k_archive_date format='F Y' /> (<cms:show k_archive_count />)</a>
</li>
</cms:archives>
Listing code:
- Code: Select all
<cms:set satisfied_clients="<cms:pages masterpage='feedback.php' custom_field='status=satisfied' count_only='1' start_on="<cms:gpc 'start_on' method='get' />" stop_before=k_next_archive_date/>" 'global'/>
<cms:set unsatisfied_clients="<cms:pages masterpage='feedback.php' custom_field='status=notsosatisfied' count_only='1' start_on="<cms:gpc 'start_on' method='get' />" stop_before=k_next_archive_date/>" 'global' />
<cms:set all_clients="<cms:pages masterpage='feedback.php' count_only='1' start_on="<cms:gpc 'start_on' method='get' />" stop_before=k_next_archive_date/>" 'global' />
<cms:php>
global $satisfied, $unsatisfied;
$satisfied = round((<cms:show satisfied_clients />/<cms:show all_clients />)*100);
$unsatisfied = round((<cms:show unsatisfied_clients />/<cms:show all_clients />)*100);
</cms:php>
Satisfied:
<cms:php>
global $satisfied;
echo $satisfied;
</cms:php>%
Not so satisfied:
<cms:php>
global $unsatisfied;
echo $unsatisfied;
</cms:php>%
Total: <cms:show all_clients />
The thing is that when testing with this scenario:
5 pages added in 01.2018
1 page added in 01.2017
This is ok: When I press on January 2018 (5) I get Satisfied: 80% Not so satisfied: 20% Total: 5
But when I press on January 2017 (1) i get the stats for all 6 pages: Satisfied: 67% Not so satisfied: 33% Total: 6
..when it should have been Satisfied: 0% Not so satisfied: 100% Total: 1
Where am I going wrong with this?