I am planning to set up a new column in one of my wpDataTable table, but i am trying to set this as a button. At the moment we can only have 1 text to represent the button text (predefined button text) as set on here https://imgur.com/ROG41M5. But can we have this button text to be the Title of the attachment like on here https://imgur.com/dwoJY2G?
My next question is can we set these to be uploaded in a separate container than the default wordpress media gallery?
Unfortunately, with the URL Link column, you can only set one Button Text, which will be applied to all buttons.
To create buttons that show different text, you will need to create a custom button, using custom CSS. For example, you can add a custom CSS class to the column, and then add code for the button in wpDataTables settings/Custom JS and CSS/Custom CSS tab. The data would have to be entered as HTML, so:
Thanks Alexandar, when you said its possible to show different text, can you show me how to do it? I dont think its anything to do with css as its just a styling code. Now main thing is how to get dynamic button text, how to inject this to the button?
How can i achieve this (similar to your suggestion)? <a href="[how to get URL value]" class="wpDataTableButton">[How to get dynamic Text based on file name in media gallery]</a>
In order to pull the file name, this table would have to be an SQL query based table. It can't be done any other way.
Basically, you'd pull the data from WP_Posts table, and using CONCAT, add the file name to the custom text.
Something like this:
CONCAT('<a href="',wp_posts.guid,'" class="wpDataTableButton">',wp_posts.post_title,'</a>') AS Attachment WHERE wp_posts.post_type = 'attachment'
It's a basic example, so you will need to work on it. You'd also need to style the button, as explained in my previous comment. You'd change the button's class from that page to "wpDataTableButton" in order for it to work.
Please note that this would require writing a custom query, and they are not included in the provided support for the plugin, so I wouldn't be able to help you with that.
Hi there,
I am planning to set up a new column in one of my wpDataTable table, but i am trying to set this as a button. At the moment we can only have 1 text to represent the button text (predefined button text) as set on here https://imgur.com/ROG41M5. But can we have this button text to be the Title of the attachment like on here https://imgur.com/dwoJY2G?
My next question is can we set these to be uploaded in a separate container than the default wordpress media gallery?
Thank you for your help.
Best,
Prima
Hello Prima
Unfortunately, with the URL Link column, you can only set one Button Text, which will be applied to all buttons.
To create buttons that show different text, you will need to create a custom button, using custom CSS. For example, you can add a custom CSS class to the column, and then add code for the button in wpDataTables settings/Custom JS and CSS/Custom CSS tab. The data would have to be entered as HTML, so:
You can create a button for free on this page, and use its code to style the button.
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
Thanks Alexandar, when you said its possible to show different text, can you show me how to do it? I dont think its anything to do with css as its just a styling code. Now main thing is how to get dynamic button text, how to inject this to the button?
How can i achieve this (similar to your suggestion)?
<a href="[how to get URL value]" class="wpDataTableButton">[How to get dynamic Text based on file name in media gallery]</a>
Best,
Prima
Hi again Prima
In order to pull the file name, this table would have to be an SQL query based table. It can't be done any other way.
Basically, you'd pull the data from WP_Posts table, and using CONCAT, add the file name to the custom text.
Something like this:
CONCAT('<a href="',wp_posts.guid,'" class="wpDataTableButton">',wp_posts.post_title,'</a>') AS Attachment
WHERE wp_posts.post_type = 'attachment'
It's a basic example, so you will need to work on it. You'd also need to style the button, as explained in my previous comment. You'd change the button's class from that page to "wpDataTableButton" in order for it to work.
Please note that this would require writing a custom query, and they are not included in the provided support for the plugin, so I wouldn't be able to help you with that.
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