Created
May 4, 2017 14:37
-
-
Save holisticnetworking/cd6fb9b7745e08eb6fcb01eef094930a to your computer and use it in GitHub Desktop.
Displaying a list of column headers from an arbitrary number of columns.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Display column headers for the user-selected array of columns. | |
* | |
* @var str $query: The query array. | |
*/ | |
public function displayColumnHeaders( $query ) { | |
$headers = ''; | |
$sort = $query['sort']; | |
$direction = $query['direction']; | |
$arrow = sprintf('fa fa-sort-%s', $direction); | |
$this->Paginator->options([ | |
'defaultModel' => 'Invoices' | |
]); | |
foreach( $this->activeColumns as $key=>$meta ) : | |
if(in_array($meta['sort_index'], $this->noSort)) : | |
$content = $meta['label']; | |
elseif($sort==$meta['sort_index']) : | |
$content = $this->Paginator->sort( | |
$meta['sort_index'], | |
sprintf( | |
'<i class="%s sort-arrow"> </i><span class="sort-text">%s</span>', | |
$arrow, | |
$meta['label'] | |
), | |
[ | |
'escape' => false, | |
'direction' => ($direction == 'ASC') ? 'DESC' : 'ASC' | |
] | |
); | |
else : | |
$content = $this->Paginator->sort( $meta['sort_index'], $meta['label'] ); | |
endif; | |
$headers .= sprintf( | |
'<th scope="col %s">%s</th>', | |
$key, | |
$content | |
); | |
endforeach; | |
return $headers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment