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

Pass data from one page to another

Solved by Ron Wardenier View solution

Started by Luca Caputo 6 years ago · 1 replies · 554 views
6 years ago

Sorry, I'm new to grav.
I have a page (page_A) which should make a php request to a forum page (page_B) with posts. page_B is not part of grav, but is an external page
page_A must take the title, date, and author of posts from page_B and print them on the screen, but must print only the last 3 posts inserted in the forum of page_B.
Does anyone help me understand how to deal with grav?

6 years ago Solution

Hello @lucapu88, welcome to the Grav Forum.

Assuming the forum with page_B does not have an API there is only one way to pull content into Grav and that's by 'web scraping'.

One approach could be to create a plugin and use the DiDOM HTML Parser library. With that it is easy to get the full HTML of page_B with:

PHP
$html = new Document();
$html->loadHtmlFile('https://www.your-forum.com/page_B');

Once you have the HTML you can manipulate it anyway you want.

To get started I suggest you read the Plugin Tutorial in the Grav Learn site and study the Page Inject Plugin and the Image Captions Plugin. The latter uses the HTML parser I pointed to.

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by jean-louis67, 3 days ago
2 85 2 days ago
General · by Andy Miller, 7 days ago
0 147 7 days ago
General · by Veehem, 1 week ago
0 146 1 week ago
General · by milkboy, 1 week ago
0 144 1 week ago
General · by ian russell, 2 weeks ago
2 227 2 weeks ago