hello there,

thanks a lot for the module, it is very helpful

i did not succeed in doing what i need

i created some view with output as JSON. the format is fine in the preview in views

i'm trying to embed this view using some hook_menu and a page callback to fire the json and then a js is rendering the json object

BUT, i do not succeed in emebeding the view to print out the json.

<?php print drupal_json(views_embed_view('myview', 'block_1')); ?>

or even

<?php print views_embed_view('myview', 'block_1'); ?>

does not seem to work
any suggestion is welcome!

Comments

miaoulafrite’s picture

in both cases it opens a windows dialog

'you have chosen to open'

which is a file of type: text/json

what shall firefox do with this file?
- open with... browse
- save

...

IncrediblyKenzi’s picture

You might try forcing the header to be application/json:

<?php 
header('Content-Type: application/json');
print views_embed_view('myview', 'block_1');
?>
anthonylindsay’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

You should not need a page callback: a views_datasource JSON view will have a path, so there is no need to embed it at all: simply call the JSON view at its path.
Then views_datasource will manage the content type header for you.