URL in Custom Template

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
wincode2008
User
Posts: 128

URL in Custom Template

Post by wincode2008 »

Dear Experts,

I want to create a download link in my custom template -list page. Here is my code

<a href='Download?fle={{{dbvalue file}}}&cl={{{dbvalue class_id}}}'></a>

Unfortunately not working.

the result is like this

http://localhost/archive/Download?fle=~root.rows[0].file&cl=~root.rows[0].class_id


arbei
User
Posts: 9437

Post by arbei »

You have wrong syntax, you may refer to Custom Template Tags -> {{{dbvalue field}}}. Read the important notes and examples in the docs.


wincode2008
User
Posts: 128

Post by wincode2008 »

if I am using a plain data, the code is working properly

  <a href='Download?fle={{url: {{{dbvalue document}}} }}' class="btn btn-sm btn-primary btn-block">
     <span class='fas fa-download'></span> Download
     </a>

But if replace the field document to field files which contain filename (Ex. 'xx.docx'). the code is not working


arbei
User
Posts: 9437

Post by arbei »

The {{{dbvalue}}} tag is mapped to field object's DbValue property, but for file upload fields, the field value is stored in the Upload property. If you need to use {{{dbvalue}}}, you may try to use Row_Rendered server event to set the field object's DbValue property, e.g.
$this->MyField->DbValue = $this->MyField->Upload->DbValue;


wincode2008
User
Posts: 128

Post by wincode2008 »

Wow. Its working. Thank you very much. Your such as excellent mentor. Thank you for your patience and guidance.


Post Reply