Extension talk:DataTable2

Jump to navigation Jump to search

About this board

Indolderivat (talkcontribs)


I'm running MediaWiki 1.31.1 on Mac OS and installed the "DataTable2" extension according to the instruction. For testing purposes, I added the code from the "demo table" example into a wikipage and received a fatal exception error of the typ "error".

Could you please be so kind and give advice? Thanks!

RV1971 (talkcontribs)

I'm afraid I'm still on MediaWiki 1.30.0. I hope to upgrade my installation in the next days. In the meantime, can you give any futher details about the error?

RV1971 (talkcontribs)

I have just upgraded my MediaWiki to 1.31.1, and everything is working. So I'd need some further details to analyze this. You might take a look at Manual:How to debug.

Indolderivat (talkcontribs)

Thanks for your answer. I have reinstalled my wiki. Now I receive the following error code:

[08a362df8789b85d404df252] /index.php?title=Main_Page&action=submit Error from line 455 of .../Wiki/extensions/DataTable2/includes/DataTable2.php: Call to undefined function wfProfileIn()
#0 .../Wiki/includes/parser/Parser.php(3888): DataTable2->renderDataTable(string, array, Parser, PPFrame_DOM)
#1 .../Wiki/includes/parser/Preprocessor_DOM.php(1362): Parser->extensionSubstitution(array, PPFrame_DOM)
#2 .../Wiki/includes/parser/Parser.php(2942): PPFrame_DOM->expand(DOMElement, integer)
#3 .../Wiki/includes/parser/Parser.php(1293): Parser->replaceVariables(string)
#4 .../Wiki/includes/parser/Parser.php(443): Parser->internalParse(string)
#5 .../Wiki/includes/content/WikitextContent.php(323): Parser->parse(string, Title, ParserOptions, boolean, boolean, NULL)
#6 .../Wiki/includes/content/AbstractContent.php(516): WikitextContent->fillParserOutput(Title, NULL, ParserOptions, boolean, ParserOutput)
#7 .../Wiki/includes/page/WikiPage.php(2129): AbstractContent->getParserOutput(Title, NULL, ParserOptions)
#8 .../Wiki/includes/page/WikiPage.php(1655): WikiPage->prepareContentForEdit(WikitextContent, NULL, User, string, boolean)
#9 .../Wiki/includes/EditPage.php(2214): WikiPage->doEditContent(WikitextContent, string, integer, boolean, User, string, array, integer)
#10 .../Wiki/includes/EditPage.php(1506): EditPage->internalAttemptSave(array, boolean)
#11 .../Wiki/includes/EditPage.php(652): EditPage->attemptSave(array)
#12 .../Wiki/includes/actions/EditAction.php(60): EditPage->edit()
#13 .../Wiki/includes/actions/SubmitAction.php(38): EditAction->show()
#14 .../Wiki/includes/MediaWiki.php(500): SubmitAction->show()
#15 .../Wiki/includes/MediaWiki.php(294): MediaWiki->performAction(Article, Title)
#16 .../Wiki/includes/MediaWiki.php(861): MediaWiki->performRequest()
#17 .../Wiki/includes/MediaWiki.php(524): MediaWiki->main()
#18 .../Wiki/index.php(42): MediaWiki->run()
#19 {main}
RV1971 (talkcontribs)

You are using an old version of the extension, the calls to wfProfileIn() have been removed in May 2018. Pls try downloading the current version.

Indolderivat (talkcontribs)

I downloaded the following version "DataTable2-REL1_31-c178d87.tar" via thisLink. My assumption was that I will receive an acutal version. Could you please advice how to proceed? Thanks again for your support!

RV1971 (talkcontribs)

I'm afraid you're perfectly right! Sorry, I failed to merge the master branch into the REL1_31 branch. I have just done that, so a corrected version should be available soon at that link.

Indolderivat (talkcontribs)

Thanks for uploading the new version. I installed it today and checked its presence under Special:Version. The extension was listed there. However, when I tested the <datatable2>-example code from extension page, the following error was generated: Fatal exception of type "Wikimedia\Rdbms\DBQueryError". Any thought on it?

RV1971 (talkcontribs)

I just realized that in some older edit on #Installation I removed by mistake the information that a database upgrade is needed to install the extension, so I guess you didn't do this. I have just corrected the instructions. Pls run the database upgrade script.

Indolderivat (talkcontribs)

Perfect. It works now. Thanks a lot!

Reply to "Extension does not work"

Add Single Record From Other Page?

Johnywhy (talkcontribs)

Possible to display textbox or input box on another page, to Add Single Record?


RV1971 (talkcontribs)

I'm afraid your question is not clear to me. Could you kindly explain more in detail what you'd like to do?

Johnywhy (talkcontribs)

Display an input box on a page.

Type data into the inputbox.

Click Submit button, and a record gets added to a table, containing the data i typed.

Type new data into the inputbox.

Click Submit button, and another record gets added to the table.

RV1971 (talkcontribs)

DataTable2 works by parsing data from wikipage text. To make your idea work, you'd need an inputbox which inserts a record into the text of a page. I'm afraid I'm not aware of the existence of an inputbox of this kind.

Reply to "Add Single Record From Other Page?"

Add Record with Extension:Page_Forms?

Johnywhy (talkcontribs)

I use Extension:Page Forms to create new pages. Can a new entry be added to a DT2 table by PageForms extension?


RV1971 (talkcontribs)

I'm afraid I do not yet use Semantic MediaWiki, so I cannot tell for sure. I depends on whether Page Forms calls the NewRevisionFromEditComplete hook at the right moment. Just try it and let me know. If it does not work out of the box, perhaps I just need to add some other hook.

Johnywhy (talkcontribs)

i'm using Page Forms without Semantic MW.

Reply to "Add Record with Extension:Page_Forms?"
Sophivorus (talkcontribs)

I just tried the extension in my MW 1.27.0 installation and when I tried to save my first table, I got an SQL exception. Some googling led me to https://phabricator.wikimedia.org/T120791 which suggests replacing the methods begin()/commit() with startAtomic()/endAtomic() respectively. I replaced them in the DataTable2Database.php file and the extension worked fine (I haven't tested all the features though). I would commit the update myself, but it's hosted at SourceForge where I'm not confortable. Could someone else take care?

Reply to "Update for MW 1.27.0"
Brettz9 (talkcontribs)

Just a feature request for Ajax-driven retrieval/filtering of sources if it might fit with your goals...

Reply to "Ajax tables"

Use standard MW table syntax?

Brettz9 (talkcontribs)

Looks like an awesome extension...Was wondering though..Would it not be possible to allow the data tables to be expressed as normal Mediawiki tables, and enhanced as necessary through standard means? (e.g., through use of `data-*` attributes)

Another question--can the showtable tag accept or be made to accept normal template syntax?

I'd feel more comfortable putting my data into this format if it was only the showtable queries which required non-standard syntax (that, and for the sake of not needing as much work to migrate old tables).

Reply to "Use standard MW table syntax?"

how to use dt2-expand the right way

~o)sabine(o~ (talkcontribs)


after upgrading to a recent mediawiki version I'm just migrating our product wiki from datatable to datatable2 and encountered a strange behaviour.

We show informations for one product on a single page, but store the data for all products on another page.

Our template for the single product page includes an includeonly part for e. g. assigning it to several product categories and a noinclude part for categorizing the template and including the Documentation template.

This is an abstracted version of the product page:

{{#dt2-expand:producttemplate|productable|pname = 'productname'}}

The product template contains

[[category:snoozer|Vintage Pro 2000]]

With this enabled the product page will be categorized as template and the product template as normal page. When I swap the includeonly / noinclude tags everything is fine. Am I missing something in calling the dt2-expand function?

Thanks in advance,


Reply to "how to use dt2-expand the right way" (talkcontribs)

Thanks for this great extension. Its going to become difficult to trust as the pages do not automatically update the pages the data is being pulled into when the table changes. I need to go to the target page, edit and click save. Is there something wrong with my configuration?

RV1971 (talkcontribs)

Pleased to know that my extension is useful. Whether your configuration is wrong depends on your needs: MediaWiki has various caching mechanisms, see Manual:Cache for an overview. Clearly you can reduce caching at the cost of performance loss. In any case, caching prevents automatic update of any underlying data; there is no way to see DataTable2 updates in real time but to allow other changes of underlying items (such as templates) to be deferred.

A simpler way to force update of a rendered page is explained in Manual:FAQ#How do I purge a cached page?.

Reply to "Automatic page updates"

Using DataTAble2 in Templates

Cruickshanks (talkcontribs)

Hello again RV1971,

I am continuing to enjoy your extension and finding it a very powerful tool.

I am now trying to use it to gather up citations used throughout my wiki. I have tried various combinations of the following code added to the {{cite news |title= |url= |newspaper= |location= |publisher= |page= |date= |accessdate= }} template.

<datatable2 table="cite news" columns = "url|title|newspaper|location|date|accessdate|page|publisher" fs=";">

However, rather than insert the parameters into the datatable2-data table for each call to the {{Cite news}} template, it only injects {{{url}}}, etc. as text in the fields. This occurs when I save the actual {{Cite news}} template in the Template namespace, and nothing is generated by saving articles.

(As I could not get it to work, I do not know whether the table="cite news" parameter would simply overwrite the same row on each instance the template was called, sometimes multiple times in one article, and I would have to use one of the template parameters to create a unique logical table name.)

I realise that the DataTable2 extension uses the NewRevisionFromEditComplete hook to save data to the database, but with my low/fundamental knowledge was hoping that via substitution/transclusion this technique might be made to work when articles were saved with calls to the {{Cite news}} template.

Would you please provide me with guidance as to whether the proposed use of the DataTable2 extension might work with some further perserverence, or the concept is fundamentally flawed due to, for instance, the NewRevisionFromEditComplete hook. If the concept is flawed, I will drop my pursuit of this idea.

Thanks in advance.

RV1971 (talkcontribs)

Dear Cruickshanks,

you're correct that the key point is the use of NewRevisionFromEditComplete. Indeed, it is the page text as saved in the database which is parsed for <datatable2> tags, without any kind of parameter expansion. It can't be otherwise because when saving the page, nothing is known about any transclusion within other pages.

So I'm afraid your idea needs to be dropped.

Cruickshanks (talkcontribs)

Thanks for you quick response RV1971. Idea is dropped. :)

Reply to "Using DataTAble2 in Templates"

Column ordering bug and two feature requests

Cruickshanks (talkcontribs)

The DataTable2 Extension is a brilliant concept and work RV1971. Your extension has been extremely helpful to me.

Column Ordering - Bug

I have discovered a bug in the data entry <datatable2> tag. After saving the page, the tag shows the content of columns in alphabetical order rather than numerical order. For example, column contents are displayed after saving a page as Column1, Column10, Column11, Column12 ... Column19, Column2, Column20, Column21 ... etc. Thus, this bug only becomes apparent when creating tables with more than 9 columns.

For example, the following code would demonstrate this:

<datatable2 table="column order test" class="wikitable" columns = "column1|column2|column3|column4|column5|column6|column7|column8|column9|column10|column11|column12|column13|column14|column15|column16|column17|column18|column19|column20|column21|column22">
! column1
! column2
! column3
! column4
! column5
! column6
! column7
! column8
! column9
! column10
! column11
! column12
! column13
! column14
! column15
! column16
! column17
! column18
! column19
! column20
! column21
! column22

Fortunately, the <dt2-showtable> tag correctly displays columns as Column1, Column2 ... Column10, Column11, Column12 ... Column19, Column20, Column21 ... etc.

Field Separator - Feature Request No. 1

I have found that the DataTable2 Extension is intolerant of '|' (pipes) field separators with whitespace on either side. I have created a table which has more than twenty columns. Each row of my input data can be quite long and screen wrapping can be an issue. Due to 'human factors', it would be easier for humans to read and prepare the input data if whitespace was permitted on at least one side of the pipes. The difficulty of not accepting whitespace with pipes is also visible with the list of columns in the code example above.

Additional SQL Statements - Feature Request No. 2

I would like to be able to use the following SQL Statements such as:

  • GROUP BY <- most important for me

I do not think the Extension permits the use of these statements (or at least I do not know how to). Could these be added too please (or explained in Help Page)?

Thanks, Cruickshanks (talk) 10:34, 22 September 2014 (UTC)

RV1971 (talkcontribs)

Pleased to know that my extension is useful to somebody.

  • The bug is fixed in version 1.0.2 which I have just published.
  • Re Feature Request No. 1, I'm not totally sure what your point is. If you'd like a <datatbase2> tag to ignore whitespace around pipes, you can instruct it to consider it part of the field separator by adding the following attribute: fs="/\s*\|\s*/"
  • Re Feature Request No. 2, one would be tempted to make a fully-functional sql database out of this extension, since it would be logical to request a JOIN feature as soon as the GROUP BY feature has been implemented. I see a number of open questions there:
    1. How to express all this in attributes to <dt2-showtable> in a way that remains understandable.
    2. How to implement all this in code that remains maintainable.
    3. How to ensure efficiency of such queries.
I'm unlikely to find solutions in the near future. As an alternative, I'd suggest to use the Lua interface, query all records you need, and do further transformations on Lua level. This is clearly not efficient for large amounts of data, but the extension is not suitable for large amounts of data anayway.
Cruickshanks (talkcontribs)

Thanks RV1971,

  • I have installed version 1.0.2 and fields and columns all correlate. Thanks for fixing.
  • Re Feature Request No. 1, I added the attribute: fs="/\s*\|\s*/" which did the trick. Earlier, I had simplistically tried things like " | " and "| " without success. Thanks for the help.
  • Re Feature Request No. 2, I understand the points you make. I discovered that the extension Extension:External_Data#.23get_db_data_-_retrieve_data_from_a_database works very well with the DataTable2 Extension and seems to provide the extra functionality I sought. Indeed, the other extension seems to have greater functionality than the author intended - see Extension_talk:External_Data#This_could_be_a_bug.
    • An additional trick I discovered by accident, is that Extension:DataTransclusion and Extension:External Data provide an easy way to look beyond/across the logical tables. This means that a large logical table can be created over several pages/templates provided that the same table structure is used with discipline. For example, using DataTable2 Extension separate templates could be set up for the members of football teams. Then using Extension:DataTransclusion and Extension:External Data, and the database column names like dtd_04, the entire list of players for the entire football league can be extracted.
    • This then means that the author has two choices: can either create and manage one table for the whole football league, or create and manage smaller tables for each football team. This could offer much utility for various Wikiprojects!
    • (I have used and like the impressive Semantic bundle too, but recognise that your extension does offer an alternative approach that suits my needs better.)

I regret not letting you know in my first post of another minor bug. It is a bug that is easily worked around. After first installing the extension and creating a page with the <datatable2> tag, the following error message was generated by both versions 1.0.1 and 1.0.2:

Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/mw/extensions/DataTable2/DataTable2.php:277) in /home/mysite/public_html/mw/includes/WebResponse.php on line 37

As there are only 275 lines of code in DataTable2.php, deleting the two 'blank' lines (276 and 277) at the end of the file fixes the error. It seems that there is some form of invisible byte order mark on one or both of those lines that is causing the upset.

Regards, Cruickshanks (talk) 10:18, 26 September 2014 (UTC)

RV1971 (talkcontribs)

Thanks for spotting the bug re blank lines. Fixed in version 1.0.3.

Reply to "Column ordering bug and two feature requests"