Hello! I need to add some styling and code to web links before they are saved, so they can be rendered correctly in a mobile app. If the user adds either a phone number or url I need them marked up per the attachment.
What would be the best tool or approach for this? A function, action, or something in the column itself such as the cell content prefix or suffix? Or conditional formatting?
The table column is defined as a link but could be a url or phone number.
I believe the best way to go about this would be through hooks - Filters.
If I'm not mistaken, for URL you'd need wpdatatables_filter_link_cell( $formattedValue, $tableId )
This filter is applied to the value of an URL link column before it is passed to the front-end.
$formattedValue is the value of the cell.
$tableId is the table identifier from the MySQL table (wp_wpdatatables).
For the phone number - I'm not sure if it would work, and perhaps you'd need to add a different filter to check if the column contains only integers, or if it's a string type column from which only numbers would be recognized and added to the URL.
Hello! I need to add some styling and code to web links before they are saved, so they can be rendered correctly in a mobile app. If the user adds either a phone number or url I need them marked up per the attachment.
What would be the best tool or approach for this? A function, action, or something in the column itself such as the cell content prefix or suffix? Or conditional formatting?
The table column is defined as a link but could be a url or phone number.
Thank you!
Hello Jocelyn.
I believe the best way to go about this would be through hooks - Filters.
If I'm not mistaken, for URL you'd need wpdatatables_filter_link_cell( $formattedValue, $tableId )
This filter is applied to the value of an URL link column before it is passed to the front-end.
$formattedValue is the value of the cell.
$tableId is the table identifier from the MySQL table (wp_wpdatatables).
For the phone number - I'm not sure if it would work, and perhaps you'd need to add a different filter to check if the column contains only integers, or if it's a string type column from which only numbers would be recognized and added to the URL.
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