Automatic URL conversion
Download:
Automatic URL conversion Extension 1.3
To add links to table cells, you’ll in general need to manually enter the HTML code for a link (something like <a href="https://www.example.com/">My Link</a>
) into a cell or use the “Insert Link” button, that will ask you for the URL and the link text and then generates the necessary HTML code for you. This is the recommended way and for most needs it works fine. It also allows for the most flexibility, because you have all freedom to alter or extend that HTML code as you like, e.g. by adding further attributes or a different link text.
Unfortunately it can be a real hassle and a lot of work, if all you want to achieve is, to make URLs you enter “clickable”, i.e. to make them valid HTML links. That can for example be the case when you import a table from a file, because in most cases URLs are not exported as HTML links by a program but simply as the plain URL in text form.
And this is were this Extension kicks in. When a table is shown in a post or page, the Extension will check if there’s an URL (for www, ftp or an email address) somewhere. And if it finds one, it will replace the URL with a complete HTML link to that URL that can be clicked by the visitor. The good thing: If there already was a complete HTML link, it will be left intact.
Here’s an example:
A cell with the content
https://www.example.com/
Code language: HTML, XML (xml)
will automatically be converted to a clickable link:
<a href="https://www.example.com/">https://www.example.com/</a>
Code language: HTML, XML (xml)
To use this, download, install, and activate the Extension like a regular WordPress plugin. Then, on the page where you want to show the table, insert the extended Shortcode
[table id=123 automatic_url_conversion=true /]
Code language: JSON / JSON with Comments (json)
and change the 123
to the desired table ID. This will activate the automatic URL conversion for that table.
Additionally, some people might want to have links open in a new browser window or tab automatically (Note that this is not recommended by web experts, as it takes away the user’s freedom and is considered bad for accessibility reasons. Personally, I totally agree with them, I hate when a site does this.). If you also want to do that, just extend your Shortcode with another parameter, to
[table id=123 automatic_url_conversion=true automatic_url_conversion_new_window=true /]
Code language: JSON / JSON with Comments (json)
The automatic_url_conversion_new_window
will add the HTML target="_blank"
attribute to the link HTML, which tells the browser to open the link in a new window or tab.
If you want links to have the rel="nofollow"
attribute set, so that search engines don’t follow the link, just add the automatic_url_conversion_rel_nofollow
parameter to the Shortcode:
[table id=123 automatic_url_conversion=true automatic_url_conversion_rel_nofollow=true /]
Single Cell Content Shortcode
Download:
Single Cell Content Shortcode Extension 1.1
For some use cases, it might be necessary to get the value of a single cell from a table.
To use this, download, install, and activate the Extension like a regular WordPress plugin. You can then use a Shortcode like
[table-cell id=123 cell=C3 /]
Code language: JSON / JSON with Comments (json)
or (if you prefer a different syntax)
[table-cell id=123 row=3 column=3 /]
Code language: JSON / JSON with Comments (json)
in your posts or pages.
Both examples would print the content of the cell C3
(third row, third column) of the table with the ID 123
to the page.
Note that this Extension will only print the “raw” and unmodified cell value. This also means that it can not be used to show e.g. calculated results of math formulas.
DataTables Sorting plugins
Download:
DataTables Sorting plugins Extension 1.0
Certain data types, such as currency values with currency symbols, numbers combined with text, or European dates, need special attention when they are sorted. The reason for that is that they differ from the data formats for which the DataTables JavaScript library has sorting algorithms built-in. To use such data types with TablePress, download, install and activate the DataTables Sorting plugins Extension like a regular WordPress plugin.
Currencies, numbers with text, and dates
Data types like formatted numbers (e.g. numbers with unit), currencies, European date formats (dd.mm(.yyyy)
or dd/mm(/yyyy)
) will then be recognized automatically, so that they are sorted correctly. Sometimes, it might be necessary to force the data type on a column. That’s possible by adding the following code to the “Custom Commands” text field in the “Features of the DataTables JavaScript library” section on the “Edit” screen of the table:
"columnDefs": [ { "type": "formatted-num", "targets": [ 2, 3 ] } ]
Code language: JavaScript (javascript)
The 2, 3
in that code is a zero-based list of all columns that shall be sorted as values with commas as the decimal separator. Here, 2, 3
means that the third and fourth column are sorted like this, as the counting starts with 0
for the first column.
Using different thousand or decimal separators
In large parts of the world, mostly the English-speaking part, a number is written like “100,000.00”, where the comma is the thousand separator, and the period is the decimal separator. In many countries, for example in Europe, the format “100.000,00” is more common. Although a number in computing usually uses the English format, TablePress can use both formats, if it’s instructed to do so. That can be done via the translation file for the DataTables JavaScript library. If the used language matches the format, this will happen automatically. Otherwise, you can use the extra parameter datatables_locale="de_DE"
(as an example for German) in the Shortcode. To set custom thousand and decimal separators, the Change DataTables String Extension can be used.
Pagination Length Change “All” Entry
Download:
Pagination Length Change “All” entry Extension 1.2
For some large tables, it can be beneficial to add an “All” entry to the Pagination Length Change dropdown box in the upper left corner of the table (if pagination is enabled). This can be achieved by using this Extension, which needs to be downloaded, installed, and activated like a regular WordPress plugin. After that, the Pagination Length Change dropdown box will have an “All” entry. If you want this to be in your language, just change the word All
in line 33
$length_menu_values[] = '"All"';
Code language: PHP (php)
of the Extension’s tablepress-length-change-all.php
file to the desired translated word. However, pay attention to not accidentally change the quotation marks around it!
Change DataTables strings
Download:
Change DataTables strings Extension 1.2
Sometimes it is necessary or desired to change certain text strings of the features like Search and Pagination, that are visible around a table. An example would be to change the word “Search:” to “Filter:” or similar. To achieve that, let’s first look at where these strings are stored. The “i18n/datatables/” folder of TablePress contains one DataTables language file for each available language. The file looks similar to this (this is the English file):
{
"emptyTable": "No data available in table",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "Showing 0 to 0 of 0 entries",
"infoFiltered": "(filtered from _MAX_ total entries)",
"infoPostFix": "",
"lengthMenu": "Show _MENU_ entries",
"loadingRecords": "Loading...",
"processing": "Processing...",
"search": "Search:",
"zeroRecords": "No matching records found",
"paginate": {
"first": "First",
"previous": "Previous",
"next": "Next",
"last": "Last"
},
"aria": {
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending"
},
"decimal": "",
"thousands": ","
}
Code language: JSON / JSON with Comments (json)
Changing strings directly in these files is a bad idea, as these changes would be reverted after each TablePress update (due to the way how plugin updates work). The Change DataTables strings Extension is a way around this problem.
Most strings in this file are self-explaining. Two of them are however not used for translations but for setting the data format of a number, e.g. for the sorting feature. Using the "decimal"
and "thousands"
parameters, the used number format can be changed. The default values in the example above will result in the traditional English format for a number, “100,000.00”. To use e.g. “100.000,00”, which is more common in Europe, the values have to be changed to "decimal": ","
and "thousands": "."
.
To use this Extension, just install and activate it like a regular WordPress plugin. Then copy the “lang-xy_XY.json” file of your language from the “tablepress/i18n/datatables/” folder to the “tablepress-change-datatables-strings” folder. (The “en_US” file is already in that folder, as an example.)
You can now change any string that is on the right side of a colon (:
) in that copied file. Make sure to not remove any of the quotation marks. Also, you can not use quotation marks in your changed strings! The words that are surrounded by an underscore (_
) are placeholders for the numbers or input fields that are automatically added by the DataTables script. You must not alter those (you can however put them in a new place within the string).
With the Extension activated, TablePress will now use the strings from the modified file.