Up2l8 Posted October 31, 2015 Share Posted October 31, 2015 Im trying to get the filename property from a file field. The file i added is a wav file. I get the url by using -> url but that is the only propery i get. I have tried with description and name and filename I have the same problem with images... i can only get url. Part of my code $animalpages = $pages->find("template=Animal"); foreach( $animalpages as $animal ) { echo($animal->AnimalSound->filename); Does not write anything echo($animal->AnimalSound->url); Gives me the url } Link to comment Share on other sites More sharing options...
Soma Posted October 31, 2015 Share Posted October 31, 2015 What url does it output? It may your file field is multiple, then AnimalSound would be an WireArray. 1 Link to comment Share on other sites More sharing options...
Up2l8 Posted October 31, 2015 Author Share Posted October 31, 2015 It gives me /pw/site/assets/files/1020/ Link to comment Share on other sites More sharing options...
Up2l8 Posted October 31, 2015 Author Share Posted October 31, 2015 Changed the field to single item, now it works! Thanks @Soma Link to comment Share on other sites More sharing options...
Soma Posted October 31, 2015 Share Posted October 31, 2015 It gives me /pw/site/assets/files/1020/ This would be the urls to the folder not the image itself, it's because you were outputing the $page->field->url and not the image because it was an array. 1 Link to comment Share on other sites More sharing options...
Up2l8 Posted October 31, 2015 Author Share Posted October 31, 2015 Strange, when I changed the field to single item i now gives me the path to the file. But it add a lot off stuff. Image field single item $animal->Animalmage->url gives me /pw/site/assets/files/1020/cat.jpg File field singe item $animal->AnimalSound->url gives me /customers/7/9/6/itsystems.se/httpd.www/pw/site/assets/files/1020/cat.wav Link to comment Share on other sites More sharing options...
Soma Posted October 31, 2015 Share Posted October 31, 2015 No idea, no it shouldn't. Then in the editor it would also have a wrong url in the file field. Link to comment Share on other sites More sharing options...
Up2l8 Posted October 31, 2015 Author Share Posted October 31, 2015 It works in the editor ... if I click the file name it opens a page and the sound play just fine!? 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