Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Get Image URL of DataObject

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 260 Views
  • darwin
    Avatar
    Community Member
    6 Posts

    Get Image URL of DataObject Link to this post

    My DataObject has one Image.

    I want to display the DataObject in JSON. In addition, I want to add the Image.Filename to the JSON Array.

    $query = "SELECT * FROM Object LEFT JOIN File ON Object.ImageID = File.ID";
    $records = DB::query($query);
    return $f->convertDataObjectSet($records);

    I guess that the $records object is no DataObjectSet, so JSON does not work. Although it works when doing DataObject::get("Object)!

    Could you please tell me how to convert the $records object to JSON? (Or is there a better way of doing this?)

    Thank you!

    260 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.