0

I have to convert the following D7 to D8 in my view twig file. I tried the following but its not working.

D7 Code :

<?php print $view->result[$id]->field_field_document_upload[0]["rendered"]["#file"]->filesize; ?>

D8 code in Twig :

   {{ view.result[id].field_field_document_upload[0]["rendered"]["#file"].filesize }}

What's the issue

1
  • You'd have to debug it to validate that is the correct structure to use in the file.
    – Kevin
    Commented Feb 26, 2019 at 19:23

1 Answer 1

0

It's impossible to say without knowing what exact template you are overriding, but you can't really convert your old PHP print statements to twig just like that.

What you can do however is put {{ dump() }} into your twig file, which is the twig equivalent to var_dump() in PHP. This will output all your available variables.

More info on {{ dump() }} here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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