Support » Plugin: wpDataTables - Tables & Table Charts » Combine Text and Shortcode in Table Cell

  • Resolved synormedia

    (@synormedia)


    Hi
    I know that it’s possible to add shortcodes to a cell.
    This would work as you could see on the table on this site I linked.
    I add shortcodes for footnotes, which will count throug the hole page by the footnote plugin.
    Unfortunately, I can’t figure out how to add a text to the shortcode so that not only the footnote is visible in the cell (number 8 in the first cell), but also a text in front of the number.
    It would be very nice to do this.
    Thanks a lot
    Stefan

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter synormedia

    (@synormedia)

    I just saw this site: https://wpdatatables.com/faqmd/can-use-shortcodes-table-cells/
    But this changes nothing.
    I thought that with this turned on maybe shortcodes will parsed in the normal text in the cell, but this will not be parsed like this.

    Either way, you have to use the “Insert Shortcode” function.
    Then this would be inserted to the table cell:

    <span data-content=”wpdt-do-shortcode” data-cell-id=”00″ data-shortcode=”[mfn]asfasdfasdf[/mfn]”>[mfn]asfasdfasdf[/mfn]</span>

    I tried to put in some text on different points, but it did not work unfortunately.
    I hope you could help me with this.

    Plugin Author wpDataTables

    (@wpdatatables)

    Hi synormedia,

    Thank you for using wpDataTables.

    There is no built-in function for such a thing, but you can use a filter where you can do with cell content whatever you need. In file wp-content/plugins/wpdatatables/templates/frontend/simple_table_html.inc.php around line 110 you have
    $cellData = apply_filters('wpdt_filter_simple_table_cell_data', $cellData, $this->getTableID());

    where the first parameter is $cellData – cell value(if in the cell is insert shortcode over editor, then that shortcode will be already executed here) and the second parameter is table id.

    Something like this you will use in your there or child theme functions.php file:

    function filterCellValue ($cellValue,$tableID){
        if ($tableID == 1){
            // do something with cell value
        }
        return $cellValue;
    }
    add_filter( 'wpdt_filter_simple_table_cell_data', 'filterCellValue', 10, 2 );

    Best regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.