DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:datatables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
plugin:datatables [2020-11-18 12:55] – [Suggestion: autolink] possible answer for autolink... roblplugin:datatables [2020-11-18 13:04] – [Suggestion: autolink] robl
Line 178: Line 178:
 One possible answer to the above is to modify the SQL query so it outputs a link. One possible answer to the above is to modify the SQL query so it outputs a link.
  
-  * To make a link clickable (where the thing returned from sql is already a URL, in field "url"):+  * To make a URL clickable (where the thing returned from sql is already a URL, in field "''url''"):
  
 <code> <code>
 <sql> <sql>
-CONCAT('<a href="',table.url,'" target=_blank">',table.url,'</a>') AS url,+SELECT 
 + CONCAT('<a href="',table.url,'" target=_blank">',table.url,'</a>') AS url, 
 +... 
 +FROM 
 +    table
 ... ...
 </sql> </sql>
 </code> </code>
  
-For example, if you wanted to make "id" a clickable link like:+To make "''id''in table "''table''" part of a clickable link:
  
-  * To put the id at the end of the link: ''https://my.website.here/100''+  * To put the id at the end of the link, e.g.: ''https://my.website.here/100''
  
 <code> <code>
 <sql> <sql>
-CONCAT('<a href="https://my.website.here/',table.id,'" target=_blank">',table.id,'</a>') AS id,+SELECT 
 + CONCAT('<a href="https://my.website.here/',table.id,'" target=_blank">',table.id,'</a>') AS id, 
 +... 
 +FROM 
 +    table
 ... ...
 </sql> </sql>
 </code> </code>
  
-  * To insert the id at somewhere in the link: ''https://my.website.here/100/details''+  * To insert the field ''id'' somewhere in the link, e.g.: ''https://my.website.here/100/details''
  
 <code> <code>
Line 204: Line 212:
 SELECT SELECT
     CONCAT('<a href="https://my.website.here/',table.id,'/details" target="_blank">',table.id,'</a>') AS id,     CONCAT('<a href="https://my.website.here/',table.id,'/details" target="_blank">',table.id,'</a>') AS id,
 +...
 +FROM
 +    table
 ... ...
 </sql> </sql>
 </code> </code>
 +
 +And other variations on this, for example if you needed multiple fields to build the URL, that's possible too with ''CONCAT''.
  
 Obviously this hack is only useful if you're using datatables with the sql plugin. It also means you can't do "''SELECT *''" because you need to modify the correct field. Obviously this hack is only useful if you're using datatables with the sql plugin. It also means you can't do "''SELECT *''" because you need to modify the correct field.
plugin/datatables.txt · Last modified: 2024-04-21 09:58 by 2001:1c04:2a92:5f00:4a0f:68f2:3f0c:20c6

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki