Show link if available as "Download" rather than field contents

sem 09 Nov, 2014
Hi. I've used HTML rather that Link to show the word "Download" instead of the field contents for uploaded files. Sometimes the filenames are really long so the table displayed looks bad. I also used HTML so that I could make the target of the link _blank.

Problem is, if there was no file upload for a record, the html still shows but with the link missing a filename. So I get presented with a blank index.html page.

Was this the best way to do this? If so, can I conditionally only display the DOwnload link if a filename is in the data record?

thanks, sem
Max_admin 10 Nov, 2014
Answer
You can try this in the HTML box:
array("" => "", "*" => "Link code goes here")

What this means is that, an empty string will be used when the field value is empty, and the link will be used for anything else.

You could also use the "PHP functions" in order to check if the field is empty and return the value you want to display:

Model.field:return (empty($row["Model"]["field"]) ? "" : "Link code goes here, and pay attention for the double quotes.");


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
sem 11 Nov, 2014
Hi Max, the HTML box method worked perfectly. Thank you.

sem
This topic is locked and no more replies can be posted.