WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp-tables plugin, table id (6 posts)

  1. subtype
    Member
    Posted 6 years ago #

    I've posted on the author's forum and emailed him with no response. Running 2.1

    When you create tables with the wp-tables plugin, it assigns the name wptable to every table. The problem with this is when you put two or more tables on one page, such as in The Loop, they each get the same table id and it throws both validator and navigation errors. Here is the code that names the tables:

    $tbl_header .= "\n".'<table class="rowstyle-alt" id="wptable" '.$act_cellspace.$act_cellpad.'>'."\n";

    I've tried assigning variables to it like a random 7 digit number, or assigning id="$table_id" to match the name of the actual table, but the plugin simply reads the variable name into the html as id="$table_id" and doesn;t interpret it. Any ideas?

  2. whooami
    Member
    Posted 6 years ago #

    what do you need the id for anyway?

    old:

    $tbl_header .= "\n".'<table class="rowstyle-alt" id="wptable" '.$act_cellspace.$act_cellpad.'>'."\n";

    new:

    $tbl_header .= "\n".'<table class="rowstyle-alt" '.$act_cellspace.$act_cellpad.'>'."\n";

  3. subtype
    Member
    Posted 6 years ago #

    Good question. Is it required for validation like the alt and name tags?

  4. whooami
    Member
    Posted 6 years ago #

    actually dont make that change, i pasted that hastily .. Ive downloaded the plugin -- let me take a look.

  5. whooami
    Member
    Posted 6 years ago #

    oke, this is what I would suggest-- so you have the id available for extra styling...

    change that line to this:

    $tbl_header .= "\n".'<table class="rowstyle-alt" id="'.$act_tablename.'"'.$act_cellspace.$act_cellpad.'>'."\n";

    what that does, is assign the name of the table as the id, so when you are in that screen that lists all your tables, you have id -- table name -- description -- so on.

    The name is used as the unique id.

    If you have a table named whoo, it will output something like this:

    <table class="rowstyle-alt" id="whoo" cellspacing="1">

    that way, you wont be re-using the same id, and you can style them a little differently if you like.

    you could still remove that bit completely like I did above, but then you would to depend on just this: class="rowstyle-alt" when doing the styling in the css.

  6. subtype
    Member
    Posted 6 years ago #

    Cool, thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic