I have a column in my database with only 2 options for each row: "Free" or "Premium"
I'd like visitors to be able to open the modal (or a post/page) only for the rows that include "Free"
(How) Can I do that?
I could (maybe) use conditional formatting to display 2 different html codes in my free/premium column, one with a hyperlink for the free entries, and one without for the premium ones (premium users would be shown a different datatable), but if that's a plan then what code do I use to link each row to their associated modal?
We are located in Serbia and our working time is from 10:00 to 17:00 CET. business days.
Well, it is not possible to do that with pop modal because you will be able to set columns to be shown for all users the same.
If I understand you right and you have this data in your database (SQL) then you can format data in your SQL query for example
SELECT column1,
column2,
column3,
column4,
CASE column4
WHEN 'Free' THEN CONCAT('<a href="link_to_free_pages">', column4, '</a>')
WHEN 'Premium' THEN CONCAT('<a href="link_to_premium_pages">', column4, '</a>')
ELSE ''
END AS 'Plan'
FROM your_table_name
Here is used CONCAT function in MySQL. On this link you have an example of how to achieve this with the query.
Of course, you will replace column1,column2,column3... with your column names
link_to_free_pages with URL that you need to free plans
link_to_premium_pages with URL that you need to premium plans
if you need to be open in a new window you will add the target attribute
(How) Is something like what you describe possible to do in this case?
I guess I could create an SQL query as you suggest rather than use the Gravity Forms addon, but am not sure which tables I would have to select. Do you have documentation on that?
You won't be able to create a table simply if you're constructing an SQL query from Gravity entries.
Gravity stores the data from forms into multiple database tables, and it requires a complex query to pull the data into a table.
Unfortunately, we do not provide support for writing custom queries, and that's why we created the integration add-on, so the query needed is being run in the background by the plugin. If you wish to construct a query outside the Gravity Add-on, you will need to create a complex query, pulling the data from Gravity's database tables.
I suppose your idea of having custom formatting would be best in this case.
I have manually created a demo table and can get the following query to work in phpMyAdmin but not in wpDataTable:
SELECT test.`id`, test.`Name`, test.`Summary`, test.`Instructions`, test.`Status`, CASE test.`Status` WHEN 'Free' THEN CONCAT('<a href="#">', test.`Status`, '</a>') WHEN 'Premium' THEN CONCAT('<a href="#">', test.`Status`, '</a>') ELSE '' END AS 'Plan' FROM test
In clear it's:
SELECT test.`id`, test.`Name`, test.`Summary`, test.`Instructions`, test.`Status`, CASE test.`Status` WHEN 'Free' THEN CONCAT('<a href="#">', test.`Status`, '</a>') WHEN 'Premium' THEN CONCAT('<a href="#">', test.`Status`, '</a>') ELSE '' END AS 'Plan' FROM test
You can try preparing a MySQL view (which will return the data that you need, call it e.g. “view1” and then build a wpDataTables based on a simple query like "SELECT * FROM view1″.
I have a column in my database with only 2 options for each row: "Free" or "Premium"
I'd like visitors to be able to open the modal (or a post/page) only for the rows that include "Free"
(How) Can I do that?
I could (maybe) use conditional formatting to display 2 different html codes in my free/premium column, one with a hyperlink for the free entries, and one without for the premium ones (premium users would be shown a different datatable), but if that's a plan then what code do I use to link each row to their associated modal?
Thank you!
Hi Sebastian,
Sorry for the late response.
We are located in Serbia and our working time is from 10:00 to 17:00 CET. business days.
Well, it is not possible to do that with pop modal because you will be able to set columns to be shown for all users the same.
If I understand you right and you have this data in your database (SQL) then you can format data in your SQL query for example
Here is used CONCAT function in MySQL. On this link you have an example of how to achieve this with the query.
Of course, you will replace column1,column2,column3... with your column names
link_to_free_pages with URL that you need to free plans
link_to_premium_pages with URL that you need to premium plans
if you need to be open in a new window you will add the target attribute
BR
Kind Regards,
Isidora Markovic
wpDataTables: FAQ | Facebook | Twitter | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Amelia demo sites | Docs
You can try our wpDataTables add-ons before purchase on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables
Much appreciated.
To be more specific, I'm using a Gravity Form.
(How) Is something like what you describe possible to do in this case?
I guess I could create an SQL query as you suggest rather than use the Gravity Forms addon, but am not sure which tables I would have to select. Do you have documentation on that?
Hi again Sebastian
You won't be able to create a table simply if you're constructing an SQL query from Gravity entries.
Gravity stores the data from forms into multiple database tables, and it requires a complex query to pull the data into a table.
Unfortunately, we do not provide support for writing custom queries, and that's why we created the integration add-on, so the query needed is being run in the background by the plugin. If you wish to construct a query outside the Gravity Add-on, you will need to create a complex query, pulling the data from Gravity's database tables.
I suppose your idea of having custom formatting would be best in this case.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Thank you for explaining.
Custom formatting won't work in this case though as it won't allow me to create dynamic links and I have too many entries to create them manually.
You're welcome, Sebastian
I'm sorry I couldn't provide any help here.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
I have manually created a demo table and can get the following query to work in phpMyAdmin but not in wpDataTable:
SELECT test.`id`, test.`Name`, test.`Summary`, test.`Instructions`, test.`Status`, CASE test.`Status` WHEN 'Free' THEN CONCAT('<a href="#">', test.`Status`, '</a>') WHEN 'Premium' THEN CONCAT('<a href="#">', test.`Status`, '</a>') ELSE '' END AS 'Plan' FROM test
In clear it's:
SELECT test.`id`,
test.`Name`,
test.`Summary`,
test.`Instructions`,
test.`Status`,
CASE test.`Status`
WHEN 'Free' THEN CONCAT('<a href="#">', test.`Status`, '</a>')
WHEN 'Premium' THEN CONCAT('<a href="#">', test.`Status`, '</a>')
ELSE ''
END AS 'Plan'
FROM test
The error message says
cannot calculate position of ('', test.`Status`, '') WHEN 'Premium' THEN CONCAT('', test.`Status`, '') ELSE '' END AS 'Plan' FROM test within , CASE test.`Status` WHEN 'Free' THEN CONCAT('', test.`Status`, '') WHEN 'Premium' THEN CONCAT('', test.`Status`, '') ELSE '' END AS 'Plan' FROM test
How do I fix that?
Thank you!
Kindly let me know.
Thanks!
Hi again Sebastian
I don't think queries that include CASE will work.
Our logic is based on a PHP SQL parser which has full support for the SQL dialect for the following statement types
SELECT, INSERT, UPDATE, DELETE, REPLACE, RENAME, SHOW, SET, DROP, CREATE INDEX, CREATE TABLE, EXPLAIN and DESCRIBE.
Some of them are disabled for security reasons.
You can try preparing a MySQL view (which will return the data that you need, call it e.g. “view1” and then build a wpDataTables based on a simple query like "SELECT * FROM view1″.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables