• Resolved dtroit

    (@dtroit)


    Hey, what would be the easiest way to add custom fields when editing the tables? Something like the existing table options fields. I need to have a setting that will change the behaviour of the table depending on the setting.

    Technically I can use table classes, but I feel it’s smoother with a field.

    • This topic was modified 2 years ago by dtroit.
    • This topic was modified 2 years ago by dtroit.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi!

    Thanks for your post and sorry for the trouble! I see what you mean, but unfortunately, I’ll have to disappoint you here. At this time, it’s not possible to add custom (settings) field to a TablePress table. You could however (programmatically) add another Shortcode parameter, or use things like “Extra CSS classes” (just as you mention) or detect a setting via the content (this is e.g. how the “Row Highlighting” and “Cell Highlighting” feature modules work).

    Now, can you maybe explain what kind of setting or behavior change you are trying to add here? Maybe I can then make a suggestion.

    Best wishes,
    Tobias

    Thread Starter dtroit

    (@dtroit)

    Hey! Thanks for the quick answer!

    I’m hooking into the markup and duplicate it in the output to have a different layout of the table on mobile, in my case I create an accordion of the table to make it easier to read the table on mobile. So with this setting I want the user to decide if the accordion items should be grouped by column titles or row titles.

    So inside this hook I need to be able to differentiate the two solutions. At the moment I can parse the class of the container but it would have felt better to just have a setting so that the client wouldn’t manually have to type a specific class every time. I guess adding a parameter to the shortcode would be more clear but you still have to type the setting manually instead of for example using a radio button.

    Every table gets stored as a post so technically they can have post meta, are there no hooks I can use to output my custom fields then? Like the same way you use the add_meta_box method from your abstract class.

    Thanks for your support!

    • This reply was modified 2 years ago by dtroit.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    Thanks for the detailed description!

    Yes, the settings are stored in a post_meta entry, but your setting would have to be added in several different places (output, frontend validation, submission to the server, server-side validation, storing in the DB again, handling on the frontend, …). And unfortunately there’s no direct way to handle all this with hooks or similar at this time. Sorry 🙁

    Regards,
    Tobias

    Thread Starter dtroit

    (@dtroit)

    Ok I see, thanks!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem! I hope to be able to modularize the code more in the future, which might allow this — but this is still an open task.

    Best wishes,
    Tobias

    Thread Starter dtroit

    (@dtroit)

    That would be awesome!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    cool! Thanks for the feedback!

    Best wishes,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Custom fields in tables’ is closed to new replies.