edwinallenz
edwinallenz

Reputation: 453

Write a Custom JsonView for cakephp

Hello I want to create a Custom JsonView class, is similar but I want format the data different, any suggestions:

Where to create the class. How to use instanciate it. Thanks in advance.

Upvotes: 0

Views: 191

Answers (1)

mark
mark

Reputation: 21743

For 2.x simply extend the current class (if possible):

App::uses('JsonView', 'View');
class MyJsonView extends JsonView {}

Otherwise you can just create a complete new one, of course.

Either way, drop it into your /APP/Lib folder:

/Lib/View/MyJsonView.php

Then you can easily use it as

$this->View = 'MyJsonView';

Upvotes: 1

Related Questions