• Resolved ryan0432

    (@ryan0432)


    Hi @tobiasbg,

    I am now importing tables from local files into my website, most of the things work well.
    Just one thing I wonder if I can change, which is the default options.
    Is there a file stored somewhere, maybe a JSON or XML that sets the default check boxes that I can make changes to?

    Thanks in advance.

    Ryan

    • This topic was modified 5 years ago by ryan0432.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Sorry, there’s no JSON or XML file for that, you’d need to use a plugin filter hook and PHP code:
    https://github.com/TobiasBg/TablePress/blob/master/models/model-table.php#L911
    That filter hook offers an array of an empty table, in which you can set default values.

    Regards,
    Tobias

    Thread Starter ryan0432

    (@ryan0432)

    Hi @tobiasbg,

    Thanks for the help.
    I have tried to change the default values as such:
    https://imgur.com/TYO2zGE

    But it doesn’t seem to make any change.
    Then I copy the block of code to functions.php, still the same.
    Can you please let me know where I should place the code and where to call get_table_template() ?

    Thanks

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    sorry, I was a bit unclear. You’d need to use the filter hook function, i.e.

    add_filter( 'tablepress_table_template', 'ryan0432_tablepress_table_template' );
    function ryan0432_tablepress_table_template( $table ) {
      $table['options']['datatables_sort'] = false;
      $table['options']['datatables_filter'] = false;
      return $table;
    }

    etc.
    This could go into your theme’s “functions.php” file.

    Note that these changes only apply to tables that are created or imported after adding this code!

    Regards,
    Tobias

    Thread Starter ryan0432

    (@ryan0432)

    Hey @tobiasbg,

    It works. ?? Now I have a better idea on how WordPress PHP works.
    Was coming from other background and not having enough experience on coding.
    Thanks a lot for helping me out ??

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change Default Options’ is closed to new replies.