here is a simple hack for sortable columns

  • nettoyeur25

    nettoyeur25 - 2006-10-18

    Here's a very simple way to get javascript sortable columns in all your awstats reports.
    I was very happy with this so I'll share my solution.

    Download the tablesort.js script from
    (script is not mine BTW)

    open your file (make backup first!) and on line 657 (I used version 6.5) where it reads:

    print "</head>\n\n";

    add a single line above to include the javascript like this:

    print "<script type=\&quot;text\/javascript\&quot; src=\&quot;http:\/\/my-personal-webserver/tablesort.js\&quot;><\/script>";
    print "</head>\n\n";

    Then scroll down to EXTRASECTIONS where the table headers are defined. (line 10360)

    add class=\sortable\&quot; to every <th> definition

    so the line
    print "<th>".$ExtraFirstColumnTitle[$extranum]."</th>";

    will look like this:

    print "<th class=\sortable\&quot;>".$ExtraFirstColumnTitle[$extranum]."</th>";

    do this also on lines 10361 until 10364.

    Done !
    Now you can click all the table headers in your extrasections to sort the tables really fast. Nice little arrows will be displayed in very tableheader to show sort order.

    Ofcourse you can also add sortable columns the same way to all sections of the awstats report, just give the <th> headers class=sortable.

    You can look further into the options (like autosorting columns when page loads) on the mentioned URL.


    • tempg

      tempg - 2009-08-27

      I've tried this every way that I can think of. It works on the first page but I can't get it to work on the second-level pages. (Meaning: It works for the extra sections on the first page but not for the pages you get to when clicking "full list")

      Anyone know where those <th>'s are defined/printed? I've tried most of the ones I see but none seem to affect the "full list" pages.

    • nettoyeur25

      nettoyeur25 - 2006-10-18

      i made a typo, where it reads


      it should ofcourse be


  • Dmitry Katsubo

    Dmitry Katsubo - 2013-02-18

    If somebody is looking for the patch, here it goes.

    Last edit: Dmitry Katsubo 2013-02-18

Log in to post a comment.