Use case: Create links dynamically using calculated column
At this tutorial we'll show how to configure a calculated column to create a working link to an url that is stored at that field.
As a first step, we'll create a new database table that will contain a list of links, together with the titles that will be stored in a separated column. If you already have your table and your links properly stored at your db table you can skip this step.
We'll use ' create table from csv', and we'll paste the information at the text area, as an example we'll create a simple list with 3 records, each one contaning a text and an url that we want to become a link when shown at the frontend.
We press 'check fields' so a couple of columns will appear. We'll name our table as 'testlinks', and we'll type both columns as 'text'. When we click 'create table' we'll see our new db table with the records already stored at the preview.
Now we'll create the Table Manager list, clicking 'new' and choosing a name and our new table 'testlinks'
In order to transform a column static data to a working link we'll configure the column 'Link' as 'calculated' and we'll enter the following code at the calculator popup:
<a href='.$Link.'>Link to '.$Title.'</a>
This code assigns a new value to the column Link, which we want to look like this:
<a href="http://www.moonsoft.es">Link to My webite</a>
so, we've replaced the url and the text for the values of each column for '$Link' and '$Title' to build dynamically a working link at that column, using the other column 'Title' as well to build the text of the link.
This is the final result:
Using this calculated column you can build complex expressions using data from all fields of the same record, any valid php expression or math operator is valid to build your dynamic content.Last modified on