01451: SimpleTables thead/tbody tags

Summary: SimpleTables thead/tbody tags
Created: 2020-02-11 02:44
Status: Open
Category: Feature
From: JeffC?
Assigned:
Priority: 2
Version: 2.2.115
OS: apache

Description: I'm trying to use jquery and datatables with pmwiki, but the formatting on simple tables does not include the necessary thead/tbody tags. I tried to make the changes noted in PITS:00970 but the must be a difference between 2.2.0 and 2.2.115 since the line numbers are incorrect, and the suggested changes throw an error. I've been able to make it partially work by making this change: from -> function PZZ($x,$y=) { $tt=;return ''; } to-> function PZZ($x,$y= null) { $tt;return ''; } but I'm now getting the tbody tag on every row, which according to PITS:00970 is fixed by this code: $td = preg_split("/$sep/", $x); $y = ''; if ($tt == 'tbody') $tt='e'; but this isn't working. Any help or direction appreciated!! JeffC? February 11, 2020, at 02:44 AM

Welcome to the PmWiki community! Please note that you should not modify core files, because this will make it harder or impossible to upgrade. And you should never need to modify core files, because every single function, markup, style, variable or value can be disabled or overridden from local configuration files. In your case, the core table markup functions are quite complex -- if you are experienced you will find and review the documentation, and the code, and will find a way to override the default functions by the ones you write. Otherwise consider creating the <thead> and <tbody> blocks in the table by JavaScript or jQuery before initiating the main jQuery extension. We do this for the core sortable tables feature (although in plain JavaScript, not jQuery) and you can review the function makesortable() in the file pmwiki/pub/pmwiki-utils.js, copy it to your script and adapt it for your needs. --Petko February 11, 2020, at 07:52 AM

Hi Petko, I'm actually a long time user of PmWiki (you helped me out a long time ago!). I'm more of a beginner python person than php, so rewriting the core table markup isn't a real possibility. Having the ability to pull in jQuery and add functionality like DataTables would be really valuable (I would love to see a cookbook recipe to add DataTables to PmWiki as a super advanced table functionality) but that requires PmWiki to generate W3 compliant tables. Is there any possibility that this functionality could be added to the roadmap? I originally tried to set the table up using <thead> <tbody> without success, but I'll give it another go. I also realize the modifying the core is not a good idea, but I'm the only user of the wiki (its my home/personal wiki), and willing to live with the inability to upgrade (at least until there's a new release with functionality I can't live without!!). Is there a way I can download Version: 2.2.0-beta63 to give it a try? Thank you very much for responding so quickly, and being so helpful!

You are incorrect, <thead> and <tbody> are not required by any W3C HTML standard, see discussion. It is likely that the jQuery plug-in expects the tables to have these tags and that's why I suggested adding them in jQuery or in plain JavaScript, before you call $('#myTable').DataTable(); which would be much simpler than in PHP, and I offered an example how we implement <thead> and <tbody> for sortable tables in a similar way. Anyways, you can download all previous PmWiki versions here: since 2.2.0-stable and before and until 2.2.0-beta68. --Petko February 11, 2020, at 08:07 PM