Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Is there a way to return full page in json format?

Started by Muut Archive 10 years ago · 3 replies · 977 views
10 years ago

Hi,

I have created a plugin that returns the web content in json format. $page->content. Is there a way to return the complete page in json? the rendered version of the page and not only the content field?
Great CMS btw!
Best regards!

10 years ago

I'm not really following you and need some more info :)

The page object itself is a PHP representation of an .md file. The content() method specifically is the primary method to access that content after it has been appropriately processed (HTML/Twig/plugins etc).

The content() method will return the fully 'rendered' view of the content assuming you have that markup in your content to begin with.

Grav however, renders the entire page through Twig template provided by the theme. This typically is what you view when you visit a website, and the {{ page.content() }} is rendered within that somewhere. The page object however doesn't have any knowledge of this final step though. You can hook into Grav itself and use the onOutputRendered() event to get that output.

10 years ago

Hi,
yeah of course: The content() method will return the fully ‘rendered’ view of the content assuming you have that markup in your content to begin with.

Nevermind, i have to used the markup for my partials in twig to be rendered.
(:
Thanks for your description.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1360 9 years ago
Archive · by Muut Archive, 9 years ago
2 938 9 years ago
Archive · by Muut Archive, 9 years ago
2 4068 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1122 9 years ago