Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.