I have a view where there was a file type field. So I added it to the view and rewrote the result for it:

used fields

<a href="{{ field_documento }}">{{ title }}</a>

The above line results in an a tag with the href for the PDF document and the node title as text for the tag.

Now I have replaced the field field_download with the field field_mdownload which is a reference to an entity of type Media document. I can't get the same result with this type of field.

I tried using Twig Tweak and Bamboo Twig for this purpose, and tried direct access to node and content too, but it doesn't seem to work in the context of the view.

I tried to use things like:


node.field_mdocument | file_uri

field_mdocument | file_uri

file_url (field_mdocument)

<% set node = bamboo_load_entity ('node', nid)%> but here twig doesn't seem to be able to convert the nid to the entire value that represents the node. If I put <% set node = bamboo_load_entity ('node', 1)%> it works.

Does anyone have any idea how I can solve this?

  • What template file are you using? – No Sssweat Feb 3 at 23:21
  • I think node.html.twig i use gavias_unix theme. – Matheus Prado Feb 4 at 12:08
  • You think??? Where are you putting the Twig Teak and Bamboo code in? – No Sssweat Feb 4 at 12:11
  • I'm not a drupal developer. Drupal is so confuse. Im my template gavias_unix i have some twing files including node.html.twig. – Matheus Prado Feb 5 at 16:41

Your Answer

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

Browse other questions tagged or ask your own question.