Skip to content

Instantly share code, notes, and snippets.

@fritzmg
Created November 21, 2015 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fritzmg/5c5ca0183074b5628d52 to your computer and use it in GitHub Desktop.
Save fritzmg/5c5ca0183074b5628d52 to your computer and use it in GitHub Desktop.
j_tablesort template which includes the default sort option provided by Contao
<?php
// Add the tablesorter style sheet
$GLOBALS['TL_CSS'][] = 'assets/jquery/tablesorter/' . $GLOBALS['TL_ASSETS']['TABLESORTER'] . '/css/tablesorter.css|static';
?>
<script src="<?= TL_ASSETS_URL ?>assets/jquery/tablesorter/<?= $GLOBALS['TL_ASSETS']['TABLESORTER'] ?>/js/tablesorter.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.0.4/js.cookie.min.js"></script>
<script>
(function($) {
$(document).ready(function() {
$('.ce_table .sortable').each(function(i, table) {
var params = {};
var sc = Cookies.get('TS_'+$(this).attr('id').toUpperCase());
if (sc) {
sc = sc.split('|');
params = {sortList: [[sc[0],sc[1]=='asc'?'0':'1']]};
}
$(table).tablesorter(params);
});
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment