This topic is locked

How to display an icon instead of download file name

10/23/2007 11:48:59 PM
PHPRunner Tips and Tricks
Sergey Kornilov admin

PHPRunner 4.2

Set both "View as" and "Edit as" types to "File" for the field that stores the filename.
Create a "After record processed" event and put the following code there:

$row[$col."Model_value"] = "<a href='Cars_download.php?field=Model&key1=". $data["ID"] ."'><img src='images/mp3.gif'></a>";


Replace 'Cars' with the actual table name, 'Model' with the column name that stores the file name, 'ID' with the key column name.

Put the correct path to icon file as well.
PHPRunner 5.0

Set both "View as" and "Edit as" types to File for the field that stores the filename.
Create a After record processed event and put the following code there:

global $record;

if ($data["Model"])

$record["Model_value"] = "<a href='Cars_download.php?field=Model&key1=". $data["ID"] ."'><img src='images/mp3.gif'></a>";


Replace 'Cars' with the actual table name, 'Model' with the column name that stores the file name, 'ID' with the key column name.

Put the correct path to icon file as well.

K
kadidarm 8/23/2008

This shows icon both when there is a file name or the field is blank. How to only show icon only when there is a file to be downloaded (that means if there is no file, the field will be blank)?

K
kadidarm 8/25/2008

Nevermind, I found the answer myself:

if($data["Model"] != null)

$row[$col."Model_value"] = "<a href='Cars_download.php?field=Model&key1=". $data["ID"] ."'><img src='images/mp3.gif'></a>";

R
Rigmantas 6/29/2010

Hi,

For all projets:

in PHPRunner5.2\source\include\commonfunctions.php replace these 787 and 788 strings:

$iquery.=$keylink;

return '<a href="download.php?'.$iquery.'">'.htmlspecialchars($ret).'</a>';


to

$iquery.=$keylink;

if($ret!='')

return '<a href="download.##@ext##?'.$iquery.'">download</a>';


Best regards

Rimantas