Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

can't show DataObject entries with JSONDataFormatter


Reply

3 Posts   1224 Views

Avatar
joninjas

17 December 2010 at 7:55am Community Member, 32 Posts

Hi all,

This JSON data just shows up on the page when I'm logged in as admin in the same browser. Does anybody has a clue why?
Otherwise it just shows this:
[url]http://www.depot43.ch/silverflash/flashinhalte/textfelder/textfeld1/jsonausgabe[/url]

class TextFeldPage_Controller extends Page_Controller {

public function jsonausgabe() {
$data1 = DataObject::get("TextFeldangabe","TextFeldangabe.Titel='$this->URLSegment'");
$f1 = new JSONDataFormatter();
return $f1->convertDataObjectSet($data1);
}

}

Thanks for your help
Jonas

Avatar
Sam

21 December 2010 at 5:15pm Administrator, 685 Posts

The data formatters check canView() before including a result.

By default, canView() returns Permission::check("ADMIN")

To fix this, override canView() for your TextFeldangabe object with an appropriate function.

Avatar
joninjas

22 December 2010 at 3:22am Community Member, 32 Posts

Thanks, really helpful!!! It works now.

Additional information of someone who implemented it this way you can find here:
http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/?commentStart=10

:-)
Jonas