3. Using the shortcode¶
A Shortcode is a WordPress method of adding dynamic content to posts and pages.
Tabulate provides one short code,
which can be used to add tables, lists, data-entry forms, and record-counts to your content.
Its parameters (which can appear in any order) are as follows:
table— The name of the table in question. Required. No default.
format— One of
record. Optional. Defaults to
ident— Used for the Record format. Optional. No default.
search— Whether to display a search form for the Table format. Optional. Defaults to
Do note that if a table is not accessible to the browsing user then nothing will be displayed. Keep in mind that you can grant access to non-logged-in users to view tables if you wish (via the Grants page in the Admin Area).
When pasting example shortcode syntax from this page into the visual editor in WordPress, be sure to use the ‘paste as text’ toolbar button: (otherwise, you will get an error such as “The ‘table’ attribute must be set” even though it looks like you’ve set that attribute). If you are using the text editor, this problem shouldn’t arise.
3.1. Table format¶
[tabulate table=widgets search=yes]
The table format displays an HTML-table displaying all records from the Tabulate-table specified.
The displayed data will be paginated if there are more than a certain number of records, and the user will be able to page through the data.
If the additional parameter
search is provided (and given any value at all;
yes is just a convention)
then a record-filtering form will be displayed.
3.2. List format¶
[tabulate format=list table=widgets]
The list format displays a comma-separated list of all of the titles of the records from the table specified.
3.3. Form format¶
[tabulate format=form table=widgets]
The form format displays a data-entry form to users who have been granted access to create records in the specified table.
The form operates exactly the same as the form in the Admin Area, except that after submission the user is sent back to a blank form in readiness for the next data-entry (rather than shown their saved data). A message such as “Record saved.” is displayed after submission.
3.4. Count format¶
There are [tabulate format=count table=widgets] Widgets in our catalogue.
The count format displays a simple integer count of the records in the given table.
This usage of the shortcode can be used inline within a sentence.
3.5. Record format¶
[tabulate format=form table=widgets ident=45]
The record format displays a single record from a table.
To specify which record to display, either provide the
ident shortcode parameter,
or set a URL parameter equal to the name of the table.
[tabulate table=widgets format=record] will look for
and display the record with a primary key value of