WordPress.org

Support

Support » Plugins and Hacks » [Resolved] wp-tables plugin, table id

[Resolved] wp-tables plugin, table id

  • 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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • whooami

    @whooami

    Member

    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";

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

    whooami

    @whooami

    Member

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

    whooami

    @whooami

    Member

    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.

    Cool, thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] wp-tables plugin, table id’ is closed to new replies.
Skip to toolbar