WordPress.org

Ready to get started?Download WordPress

Forums

How do I add a custom CSS class to select tables? (13 posts)

  1. johnflufin
    Member
    Posted 3 years ago #

    Can this be done through a custom data field? If so how is this done.

    Thanks.

    John

  2. TobiasBg
    Member
    Posted 3 years ago #

    Hi,

    I'm not sure what exactly you are trying to achieve.
    Can you explain a little bit more in detail, please? Maybe with an example?

    Thanks!
    Tobias

  3. johnflufin
    Member
    Posted 3 years ago #

    By default you can only apply custom styles to a subset of tables by using their id dependent css class. For example:

    .wp-table-reloaded-id-7, wp-table-reloaded-id-12 {
        ...custom css...
    }

    This method requires the style sheet to be edited everytime a new table is added to the subset. It would be far more convenient to customize a subset of tables if there was a way to assign a custom css class on an individual basis. For example:

    <table>...
    <table class="group1">...
    <table class="group1">...
    <table>...
    <table class="group2">...
    <table class="group2">...

    Does your plugin allow this?

  4. johnflufin
    Member
    Posted 3 years ago #

    Actually .type1 and .type2 are probably better class names (rather than .group1 and .group2) but I hope you get the idea.

  5. TobiasBg
    Member
    Posted 3 years ago #

    Hi,

    thanks for that detailed explanation.
    Now I understand what you are talking about :-)

    Unfortunately, currently that is not easily possible with the plugin, but I have something like that on my feature request list already, and will be working on it for a future version (I have a table templating system in mind, where you can select a template (or group or type) for a table, so that that will be used for the CSS styling.
    I did not yet have the time to start working on this though :-(

    Meanwhile, one possibility to achieve something like this, would to create a plugin that uses the "wp_table_reloaded_table_css_class" filter to add your custom CSS class there. However, in that filter function you will need to maintain a list of which table ID belongs to which CSS group.

    Best wishes,
    Tobias

  6. johnflufin
    Member
    Posted 3 years ago #

    Sounds great! Meanwhile, how difficult would it be to edit your current plugin code so that it allows a custom class to be assigned through the short code like so [table id=6 class=type1 /]?

    I see that your plugin consists of several files so if you could kindly point me to the appropriate files I would greatly apprciate it.

  7. TobiasBg
    Member
    Posted 3 years ago #

    Hi,

    I actually have some code for that ready, as an Extension to WP-Table Reloaded. It does not even modify the plugin files, but uses the filter hooks.

    Can you contact me by mail, so that I can send it to you? My address is in the main plugin file.

    Best wishes,
    Tobias

  8. danielb
    Member
    Posted 3 years ago #

    It would be very nice to have an ability to assign a class to a table.

    I've set up two several sets of CSS rules for different types of tables. Currently it seems like the only option to run several "table classes" is to add each table ID to corresponding CSS selector, which is not very handy.

    TIA

  9. TobiasBg
    Member
    Posted 3 years ago #

    Hi Daniel,

    yes, as mentioned above, I will try build something like that for a future version.

    Meanwhile, if you are also interested in that custom Extension described above (which allows adding a CSS class to a table with another Shortcode parameter), just contact me by email and I will be happy to share it with you.

    Best wishes,
    Tobias

  10. johnflufin
    Member
    Posted 3 years ago #

    Hi again Tobias,

    I just noticed that version 1.8 of your plug-in is out and I wanted to see if your CSS class extension still works with the new version. Or has this functionality been rolled into 1.8?

    If not, is 1.7 and the extension compatible with WordPress 3?

  11. johnflufin
    Member
    Posted 3 years ago #


  12. johnflufin
    Member
    Posted 3 years ago #

    BTW, why is the book "WordPress Plug-In Development (Beginner's Guide)" on your Amazon wishlist? Clearly you are NOT a beginner :)

  13. TobiasBg
    Member
    Posted 3 years ago #

    Hi John,

    both WP-Table Reloaded 1.7 and 1.8 work von WP 3 (of course I always recommend using the latest version!).
    The Extension should also still work (it was not integrated into 1.8, but remains separate).

    And regarding that book: Although it names itself "Beginner's Guide", I'm pretty sure that even I can learn a lot from it, don't worry :-) After all, its author is a real WP expert.

    Best wishes,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Topic