felted Posted January 18, 2020 Share Posted January 18, 2020 Hi, i created a repeater-field with an file-field in it. I get the filename with this code: foreach ($page->Downloads as $download) { $ext = pathinfo($download->Datei, PATHINFO_EXTENSION); $content .= "<i class='material-icons mr-2 float-left'>save_alt</i>"; $content .= "<a target='_blank' href='".$download->Datei->url.$download->Datei."'>".$download->Datei->Beschreibung."</a> <span class='btn-secondary pl-1 pr-1'>".$ext."</span><br />"; } But i cant get the description (Beschreibung) from the file-field. Can anybody help me? Thanks, Felted Link to comment Share on other sites More sharing options...
MoritzLost Posted January 18, 2020 Share Posted January 18, 2020 The machine names of system fields are always in english, so you need to access the description like this: $description = $download->Datei->description(); By the way, there's also a utility method for the file extension: $extension = $download->Datei->ext(); Also, if your Repeater only contains the file field, you could also get rid of the Repeater altogether and just allow multiple files on the "Datei" field. Then you could iterate it directly: foreach ($page->Datei as $file) { $url = $file->url(); $ext = $file->ext(); $description = $file->description(); // output download links here ... } Look up the Pagefile API documentation for a list of all available utility methods. 2 1 Link to comment Share on other sites More sharing options...
felted Posted January 18, 2020 Author Share Posted January 18, 2020 (edited) Ok, now i understand. Thank you very much! Detlef Edited January 18, 2020 by felted Bad english :) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now