Support » Plugins » [Plugin: WP-Table Reloaded] Datatables custom commands in Shortcode and Template tag

  • Resolved mlynge

    (@mlynge)


    Hi Tobias

    I got the following issue with WP-table-reloaded.

    When updating a really large table the “Table Styling Options” and “Data Tables JavaScript Features” disable and the “Data Tables JavaScript Features Custom Commands” is lost.
    Adding the parameters to the Shotcode and Template tag is my solution to this problem. However I can’t figure out how to add datatables custom commands to the Shortcode or Template tag.

    I noticed that you list the parameter: “datatables_customcommands”.
    is this the one to use when wanting to add the following custom commands: "sPaginationType": "full_numbers", "iDisplayLength": 50, "aaSorting": [[1,'desc'], [2,'desc']]

    Is this possible and how?

    I would appreciate an answer both on how to add custom commands and if you now the source to the problem.

    Thank you in advance 🙂

    http://wordpress.org/extend/plugins/wp-table-reloaded/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    thanks for your question!

    The source of the problem is very, very likely the Suhosin PHP extension, see http://wordpress.org/support/topic/289836
    The symptoms are pretty equal.

    Really nice idea to work around this with the Shortcode parameters. I’ll have to remember that! 🙂

    You are right, there also is a Shortcode parameter “datatables_customcommands”. The problem with it that (as in your case), the Custom Commands usually contain quotation marks (“) and single quotation marks (‘).
    However, those are used by the WordPress Shortcode API engine to actually parse the Shortcode and determine the parameters, so you can not use both of them in your Custom Command.
    So, changing the ” to ‘ should do the trick.
    Can you try this Shortcode?:
    [table id=1 datatables_customcommands="'sPaginationType': 'full_numbers', 'iDisplayLength': 50, 'aaSorting': [[1,'desc'], [2,'desc']]" /]

    That should not make any trouble hopefully 🙂

    Best wishes,
    Tobias

    Thread Starter mlynge

    (@mlynge)

    Hi. Thank you for your as usual for your quick reply 🙂
    Changing the ” to ‘ did the trick for:

    [table id=1 datatables_customcommands="'sPaginationType': 'full_numbers', 'iDisplayLength': 50" /]

    However datatables_customcommands="'aaSorting': [[1,'desc'], [2,'desc']]" didn’t work. I think WP misinterpret the brackets []

    So my solution was to make a template with the following WP-table-reloaded template tag. The custom commands works as intended when using the Template Tag.

    <?php wp_table_reloaded_print_table( "id=1&use_tablesorter=true&print_name=false&alternating_row_colors=true&row_hover=true&first_row_th=true&datatables_sort=true&datatables_paginate=true&datatables_lengthchange=true&datatables_filter=true&datatables_info=true&datatables_customcommands='sPaginationType': 'full_numbers', 'iDisplayLength': 50, 'aaSorting': [[1,'desc'], [2,'desc']]" ); ?>

    Hope that some one out there can find this useful. Again thanks for your support Tobias.

    Regards

    Martin Lynge

    Hi,

    yes, totally right. The closing bracket ] basically ends the Shortcode, so that WordPress doesn’t recognize all parameters.
    Unfortunately I don’t know a solution for that, as the ] can not be escaped. There’s also no other character that can be used like it was possible with the ‘ and “.

    So, good that you found the solution with the Template Tag. It’s not as nice as the Shortcode, but it works 🙂

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP-Table Reloaded] Datatables custom commands in Shortcode and Template tag’ is closed to new replies.