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   1279 Views

Avatar
joninjas

Community Member, 32 Posts

17 December 2010 at 7:55am

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

Administrator, 685 Posts

21 December 2010 at 5:15pm

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

Community Member, 32 Posts

22 December 2010 at 3:22am

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