Okay
  Public Ticket #1002414
Dynamic Link
Closed

Comments

  •  2
    Carl Gross started the conversation

    Hi,

    I'm trying to edit the value of each cell in a hyperlink column to add the correct link dynamically (which is different depending on the cell value and table ID). The wpdatatables_filter_link_cell filter looked promising, but it doesn't pass the table ID, which I need. Is there any filter I could use which will pass the table ID and allow the return of the value of each cell in a hyperlink column? 

    Thanks!

  •  1,688
    Miloš replied

    Hi Carl,
    Thank you for your purchase,

    It is a good point and we will see how to pass the table ID to the column-related hooks for future versions to simplify the future customizations.

    For now unfortunately there's no way to do this, the only workaround we can think of is to include some unique placeholder in the cell itself, and then search for it in the wpdatatables_filter_link_cell hook, i.e.,

    to each cell in the table where you want to adjust the content dynamically add something like %%REPLACEME%%

    then in the wpdatatables_filter_link_cell hook you can look for this placeholder and replace it with what you need like:

    if( strpos( $cellValue, '%%REPLACEME%%' ) !== false ) {
        $cellValue = str_replace( '%%REPLACEME%%', 'yourdynamicstring', $cellValue ); } return $cellValue;

    Hope this helps.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia 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

  •  2
    Carl Gross replied

    Thanks for the reply. 

    How would you suggest adding the %%REPLACEME%% text to the cell? Since it is a URL link cell, the 'Display Text Before' and 'Display Text After' options do not seem to work. 

    I am currently using a CONCAT modifier in the query itself, which correctly adds the variable to the original cell value. I then have a wpdatatables_filter_link_cell hook to make the table-dependent edit. However, returning a value using either this notation: http://wpdatatables.com||Check out wpDataTables, or an html-style link (a href), I get a JSON error. What is the proper format for the return value of a wpdatatables_filter_link_cell hook?

    Thanks,

    Carl

  •  2
    Carl Gross replied

    Never mind, there was an error elsewhere causing the JSON issue. I should be able to get this to work now, thanks.