• Resolved dostrog

    (@dostrog)


    Hi Tobias!

    Thanks for your great job!

    I have on small question. Is there any way to direct import new (csv) table?

    I developed plugin where get data from other server by API and store them in CSV file. Then I would like to put it to site’s DB for future operating by TablePress (set AutoImport options, etc).

    Do I need to make 2-dimensional json data in #_posts table (make changes in #_options etc) or is there any function/methods in TablePress controllers/models to make this?

    I can make HTTP request like from TablePress Import tabs with posts params, but it is not right way, I think.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    If you already have the data in your plugin, you shouldn’t even need the CSV file (unless you want the CSV file for something else of course).
    However, instead of directly manipulating the table data in the database, which is not very fail-safe, I would recommend to simply do it in the same way as TablePress, when it saves a modified table after a user edits it. So, basically, you could extract the relevant code from the controller, see https://github.com/TobiasBg/TablePress/blob/master/controllers/controller-admin_ajax.php#L68

    Alternatively, you could trigger a manual import of CSV data in the same way as e.g. the TablePress Extension from https://tablepress.org/extensions/table-auto-import/ does it. Just check its code.

    Regards,
    Tobias

    Thread Starter dostrog

    (@dostrog)

    Thanks for your advice, Tobias! In the end, I successfully solved my problem.

    I copied a few snippets from your code (private methods), but tried to call the TabletPress classes public methods directly. I hope that I did not violate the license.

    Thank you for you great job and well documented code!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great! Good to hear that you could make it work!

    And no worries about the license, this is all ok ??

    Regards,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Programmatically import new table’ is closed to new replies.