Hi,
I've been trying to find the best way to share a basic JSON View
across my application. The view is quite simple and only contains :
<?php echo json_encode($response) ; ?>
The view is used across the application thorough a utility method in
the AppController :
protected function renderJSONResponse($response) {
$this -> RequestHandler -> setContent('json', 'application/json');
$this -> set('response', $response);
$this -> render('json');
}
Only problem now is having to re-create the same view, which doesn't
take more than 5 seconds everytime, but is not very DRY, and is messy
and redundant.
A quick and dirty solution which works is to put the view in a common
folder under the View folder and render it using :
$this -> render('../Common/json');
Just wondering if :
a) There is a better way of achieving the same thing.
b) There are any objections against doing this or any reasons why its
not a good idea ?
Cheers,
Shuku.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php