Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
miaoulafrite CreditAttribution: miaoulafrite commentedin both cases it opens a windows dialog
'you have chosen to open'
which is a file of type: text/jsonwhat shall firefox do with this file?
- open with... browse
- save
...
Comment #2
IncrediblyKenzi CreditAttribution: IncrediblyKenzi commentedYou might try forcing the header to be application/json:
Comment #3
anthonylindsay CreditAttribution: anthonylindsay at Annertech commentedYou 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.