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.

General

Pass data from one page to another

Solved by Ron Wardenier View solution

Started by Luca Caputo 6 years ago · 1 replies · 460 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 Jerry Hunt, 4 days ago
2 80 9 hours ago
General · by pamtbaau, 14 hours ago
1 51 13 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago