Score:-2

How can I render a view as JSON inside a template file?

ph flag

I would like to render a view as JSON, within the page template. I would hide it with CSS and use it with JavaScript.

Is there a way to alter the Format field used when creating a view, which normally shows options like Grid, HTML List?

I did try the Rest Export core module, but it seems to render the view as JSON with no other page content.

apaderno avatar
us flag
Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/127163/discussion-on-question-by-hayden-thring-how-can-i-render-a-view-as-json-inside-a).
Score:0
ph flag

Though originally I wanted to avoid making subsequent requests to the server, it seems its the easiest way to get around this. Just make some views that output json and load them with ajax.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.