0

I have a file entity field that I can upload multiple files and I'm trying to render or display it inside my node twig template. The code below is what I'm trying to make it display. Tried clearing my cache but it still shows empty.

I can display the url/uri of a single file upload but I can't seem to figure out how I can display multiple upload files url/uri in the loop.

Single file here:

<a href="{{ file_url(node.field_upload_file.entity.uri.value) }}">Download File</a>

Multiple files Here:

{% for key,value in node.field_upload_file.value %}
  <a href="{{ file_url(node.field_upload_file.entity.uri.value) }}">Download File</a>
{% endfor %}

Is this a way to display multiple upload files url/uri in the loop? Please suggest to me.

0

You can try to loop over the field items:

{% for item in node.field_upload_file %}
  <a href="{{ file_url(item.entity.uri.value) }}">Download File</a>
{% endfor %}
  • Thank you very much. it's working fine :) – Punya Ruchal Mar 12 at 4:04
  • 1
    Thank you for the feedback. Click on the green check mark if it's working fine. – user89751 Mar 12 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.