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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

How to turn Json data into a table in page

Started by longh 2 years ago · 6 replies · 387 views
2 years ago

Hello,
I have a beginner's question because I don't understand how to do this. I'm trying to interpret a json so that it appears formatted in HTML.
I thought that all I had to do was paste my json into a page and create an item.json.twig for it to work?
I'd like an HTML page as a result instead of the json interpretation.
How do I go about it?
Thank you very much for your help

2 years ago

@longh, Surround the json in your markdown with triple backticks, like:
<pre>

JSON
{
  "name": "Name of user"
}

</pre>

This which will show as:

JSON
{
  "name": "Name of user"
}

No need to use a item.json.twig

2 years ago

thanks for the reply but I've mistranslated my request?

I would like to put a json in the backoffice in edit page and get HTML in the frontpage.

2 years ago

@longh, Please provide more details:

  • What does the json look like?
  • What do you expect to see in the front-end?
  • What do you see instead?
2 years ago

i would like :
image|388x500

My result is a json file

2 years ago

@longh, That information is quite different from the original question...
Update: I've taken the liberty to alter the title

Try plugins "Table Importer"

The Table Importer Plugin is for Grav CMS. It imports tables from JSON, YAML, and CSV formats into a page.

And/or plugin Import:

This plugin allows you to import YAML and JSON files into the header of your pages, facilitating custom actions/settings.

Note:

  • Both plugins are abandoned.
  • I have no experience with either of the two.

Update: Plugin Table Importer is going to be taken over by new maintainer.

last edited 04/23/24 by pamtbaau
2 years ago

I was going to mention the table importer plugin as well to accomplish what you are trying to do @longh. The only caveat here is that your JSON content is attached to the page as a file and not embedded in the page content

I am working to get it updated to work correctly with Grav 1.7 and PHP 8 right now. I plan to have a release out later this week.

👍 2

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 90 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 449 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 44 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 123 3 months ago