Skip to content

Instantly share code, notes, and snippets.

@techjewel
Last active November 1, 2023 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save techjewel/55703124534f1aba9b70cf0f605a793e to your computer and use it in GitHub Desktop.
Save techjewel/55703124534f1aba9b70cf0f605a793e to your computer and use it in GitHub Desktop.
Ninja Tables Advanced Shortcode Usage
<?php
// The following Table Shortcode will show 5 rows per page
[ninja_tables id='YOUR TABLE ID HERE' per_page=5]
// The following Table Shortcode will not show search bar
[ninja_tables id='YOUR TABLE ID HERE' search=0]
// The following Table shorcode will disable table sorting
[ninja_tables id='YOUR TABLE ID HERE' sorting=0]
// The following Table shorcode will not show header row
[ninja_tables id='YOUR TABLE ID HERE' hide_header=1]
// The following Table will be rendered only for logged in users
[ninja_tables id='YOUR TABLE ID HERE' logged_in_only=1]
// The following Table will search for URL parameter "table_filter" and then
// Use that value for table filter
// ex: domain.com/table_page/?table_filter=ninja
[ninja_tables id='YOUR TABLE ID HERE' get_filter='table_filter']
// The following Table will search for john and show only the match results
[ninja_tables id='YOUR TABLE ID HERE' filter='john']
// The following Table will search for john and show only the match results and as well user can not reset the filter
[ninja_tables id='YOUR TABLE ID HERE' filter='john' hide_default_filter="yes"]
// The following table will show only the name,email,phone column
[ninja_tables id='YOUR TABLE ID HERE' columns="name,email,phone column"]
// filter_selects:
// If you want to add multiple pre-defined selected value you can do that like this:
[ninja_tables id='YOUR TABLE ID HERE' filter_selects="FILTER_TITLE_1=defaultValue1|FILTER_TITLE_2=defaultValue2"]
// limit If you want to limit the data then you use this parameter.
[ninja_tables id='YOUR TABLE ID HERE' limit="20"]
//If you want to skip few rows from your table’s data source then you use this parameter.
// It will skip first 10 rows from your table’s data source.
[ninja_tables id='YOUR TABLE ID HERE' skip="10"]
/*
info: This parameter let you show the table meta info after pagination.
Available Placeholders:
{CP} – The current page.
{TP} – The total number of pages available.
{PF} – The first row number of the current page.
{PL} – The last row number of the current page.
{TR} – The total number of rows available.
*/
[ninja_tables id='YOUR TABLE ID HERE' info='Current Page {CP} of {TP}']
@joram-sjamaar
Copy link

Line 9: shorting -> sorting

@maddobs
Copy link

maddobs commented Apr 19, 2021

Hi, awesome idea. I would be willing to donate 100$ if you modify/add the function to put the SQL query for the table into the shortcode aswell. Then I could use one table template and wouldn’t need to create 1000 tables that only differ minimally in their queries. Thanks :-)

@StevenJerez
Copy link

Hi, awesome idea. I would be willing to donate 100$ if you modify/add the function to put the SQL query for the table into the shortcode aswell. Then I could use one table template and wouldn’t need to create 1000 tables that only differ minimally in their queries. Thanks :-)

+1

@andywebapp
Copy link

If we have to hide a few columns only for mobile and tablet devices how to use this feature

@Malkavian77
Copy link

i have a table with diferent users info. But i want to display the current logged user info only (they have a user-dashboard), how can i do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment