Jump to content

Recommended Posts

Posted

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
}
 
 
 
Posted

What url does it output?

It may your file field is multiple, then AnimalSound would be an WireArray.

  • Like 1
Posted

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. 

  • Like 1
Posted

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
Posted

No idea, no it shouldn't. Then in the editor it would also have a wrong url in the file field. 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...