• Resolved bapreiss

    (@bapreiss)


    Hello I am having a problem with links importing into tablepress from gravity forms. Basically I have a field in gravity forms that asks for a link. The link exports in a cvs file and imports to the table. That works great and all the data I need is in the table. The link is not clickable and really long. I can make it clickable but can’t figure out how to change it to say “click here”. I can use a href on individual cells to make it work but I want it to work for an entire column.

    If the solution doesn’t involve adding php or java directly to the plugin that would be great. Maybe dynamic population would work?

    Ill take any solution though!

    • This topic was modified 5 years, 8 months ago by bapreiss.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    For this, you could then maybe use a JavaScript renderer. For that, please try adding this to the “Custom Commands” text field on the table’s “Edit” screen:

    "columnDefs": [ { "render": function ( data, type, row, meta ) { if ( 'display' === type ) { data = '<a href="' + data + '">Click here</a>'; } return data; }, "targets": [ 4 ] } ]
    

    The 4 near the end of the command has to be changed to the number of the column with the URLs, but minus 1 (because counting starts with 0).

    Regards,
    Tobias

    Thread Starter bapreiss

    (@bapreiss)

    I wasn’t able to get that to work.

    I added \ around the href
    and was able to get a clickable link but instead of going to a different site it goes to a 404 error and my links look like:

    https://kcsteachertools.com/kcs-toolkit/www.khanacademy.org/

    Solutions?
    When I view the source code of the table I don’t see any html in the table.

    Should I just use php?

    • This reply was modified 5 years, 8 months ago by bapreiss.
    • This reply was modified 5 years, 8 months ago by bapreiss.
    • This reply was modified 5 years, 8 months ago by bapreiss.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    I’m not sure why you added the \ around the href, that should not be necessary.

    The cause for these wrong URLs is that your URLs in the imported table don’t have a prototol, i.e. they are just

    www.khanacademy.org
    

    and not

    https://www.khanacademy.org
    

    I recommend to either add the protocol (https:// or https://) before every of these domains or alter the JavaScript code to prepend https://:

    "columnDefs": [ { "render": function ( data, type, row, meta ) { if ( 'display' === type ) { data = '<a href="https://' + data + '">Click here</a>'; } return data; }, "targets": [ 4 ] } ]
    

    Regards,
    Tobias

    Thread Starter bapreiss

    (@bapreiss)

    I was able to get it working using:

    "columnDefs": [ { "render": function ( data, type, row, meta ) { if ( 'display' === type ) { data = "<a href=\"" + data + "\">Click here</a>"; } return data; }, "targets": [ 5 ] } ]

    and I did know it needed to be https:// I changed the first one to just www as a control subject when I was trying to figure out why it wasn’t working.

    Thanks for the help!

    • This reply was modified 5 years, 8 months ago by bapreiss.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Changing links to “click here” for an entire column’ is closed to new replies.