cerebrate/app/templates/element/genericElements/IndexTable/Fields/count_summary.php

26 lines
734 B
PHP
Raw Normal View History

<?php
/*
'name' => __('Members'),
'data_path' => 'alignments',
'element' => 'count_summary',
'url' => '/individuals/index/?organisation_id={{url_data}}',
'url_data_path' => 'id'
*/
$data = $this->Hash->extract($row, $field['data_path']);
if (!empty($field['url_data_path'])) {
$url_data_path = $this->Hash->extract($row, $field['url_data_path'])[0];
}
if (!empty($field['url']) && count($data) > 0) {
if (!empty($url_data_path)) {
$field['url'] = str_replace('{{url_data}}', $url_data_path, $field['url']);
}
echo sprintf(
'<a href="%s">%s</a>',
h($field['url']),
count($data)
);
} else {
echo count($data);
}
?>