Closed jimhaakman closed 4 years ago
Hi. Not sure this is related to Twig. If you try with a PHP template, can you get the URL? For example with:
<?php echo $page->myfield()->toFile()->url(); ?>
In Twig you would use the same Kirby API, the only difference is the slightly shorter syntax.
If you can't get a correct result in PHP, a better place to ask would be the Kirby forum or, if you believe it's a bug in Kirby, https://github.com/getkirby/kirby/issues
I get a result in php, the url of the file http://localhost:3000/content/test/test.mp4
instead of (unknown).
Apparently we should call the url method explicitly:
{{ page.myfield.toFile.url }} -> ""
{{ page.myfield.toFile.url() }} -> "/content/foo/bar.jpg"
That's usually not needed in Twig in my experience (and according to their doc) but it seems this object class is implemented in a way that is fooling Twig into getting a null
value.
When using
page.field.toFile.url
it returns(unknown)
whilepage.field.toFile
returns the filename anddump(page.field.toFile)
returns an object. How do I get the URL?