We're Moving to a New Support Platform – Starting June 1st!

We’re excited to let you know that starting June 1st, we’ll be transitioning to a new support system that will be available directly on our product websites – Amelia, wpDataTables, and Report Builder. In fact, the new support platform is already live for Amelia and wpDataTables, and we encourage you to reach out to us there.

You'll always be able to reach us through a widget in the bottom right corner of each website, where you can ask questions, report issues, or simply get assistance.

While we still do not offer live support, a new advanced, AI-powered assistant, trained on our documentation, use cases, and real conversations with our team, is there to help with basic to intermediate questions in no time.

We're doing our best to make this transition smooth and hassle-free. After June 1st, this current support website will redirect you to the new "Contact Us" pages on our product sites.

Thanks for your continued support and trust – we’re excited to bring you an even better support experience!

Okay
  Public Ticket #2519072
Formatting a column as a link
Closed

Comments

  •  1
    Norm Sash started the conversation

    Hi... I've parsed through the docs but couldn't find an answer to this. I'll simplify the setup to just focus on this one thing.

    I have a non-wp db that I'm going to retrieve two columns from:

    • item_id (example value 1234)
    • item_hash (example value secret-hash1234)

    When displaying the item_id column I need to format it in the form of a link so that users can click on the item_id and be taken to a page url defined by item_hash.

    So the item_id column would show 1234 as a link formatted something like https://my-domain.com/secret-hash1234

    Is this something that can be done and can you provide me some instructions?

    Thanks,

    -Norm

  •  1
    Norm Sash replied

    I'm making some progress on this request through trial and error.  I found another ticket post looking for a way to filter column data and found "wpdatatables_filter_cell_output".  It is getting me closer but it still isn't quite what I need.

    That filter seems to return the formatted cell data after it has been converted into a link (if the column is defined as a link type.)

    What I need is a filter that accesses the column data before it is formatted into the url. That way I can insert the correct link address for the cell value including the dual pipe characters (e.g. "https://mydomain.com/cellvalue||cellvalue".  

    Then, since the cell is now formatted the way wpDataTables wants it, it can then pass through the column formatter and return the desired final link.

    So.... is there a filter similar to 'wpdatatables_filter_cell_output' that gets the cell data before it is formatted?  Something like 'wpdatatables_filter_cell_value'.

  •  2,576
    Aleksandar replied

    Hello Norm

    Thank you for your purchase.

    Since you're creating an SQL query based table, no need to complicate it with filters or hooks.

    You can use CONCAT for this. I'll use your example: item_id column would show 1234 as a link formatted something like https://my-domain.com/secret-hash1234

    SELECT item_hash,
            CONCAT('<a href="https://my-domain.com/secret-hash', `table`.`item_id`, '">', `table`.`item_id`, '</a>') AS item_id
    FROM table

    To break it down, it will concatenate 

    https://my-domain.com/secret-hash + item_id into a HTML "a href" tag, add the item_id as a hyperlink, and that's it.

    So, in HTML terms, it would look like this:

    <a href="https://my-domain.com/secret-hash1234>1234</a>

    And users would see it like 1234.

    I hope that helps.

    Kind Regards, 

    Aleksandar Vuković
    [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

  •  1
    Norm Sash replied

    Thanks Aleksandar.  Using SQL concat is a good idea.  I thought about using it - and I believe it would work in some situations - but it won't quite work for my explicit case.

    I did simplify the use case in my OP, but as usual, there's always more to the story.  In this case, I can't just use concat with static values.  The leading portion of the URL will change depending on data in the cell.  So therefor I have to dynamically build the leading part of the link. That is, in some cases the leading part of the link might be "https://mydomain.com/section1/cell-value" while in another case it might be "https://mydomain.com/section5/cell-value"

    So that's one of the reasons I'm looking for a filter.  Something like a filter similar to 'wpdatatables_filter_cell_output' that gets the cell data before it is formatted?  Something like 'wpdatatables_filter_cell_value'.

    Also... is there an object or filter that returns all of the current row values?  This would be useful if needing to make decisions in one column based on the data value in another column.

    Thanks,

    -Norm


  •  2,576
    Aleksandar replied

    Hi again Norm

    Yes, wpdatatables_filter_cell_output returns a formatted link. We don't have a filter, but you could use the object

    $wpDataTable = $wpDataTable = WPDataTable::loadWpDataTable($tableId);
        $data = $wpDataTable->getDataRows();
        $dataFormatted = $wpDataTable->getDataRowsFormatted();


    Kind Regards, 

    Aleksandar Vuković
    [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