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.

Support

Access Grav functions outside directory

Started by Matt Shultz 9 years ago · 6 replies · 573 views
9 years ago

I have Grav installed to a subfolder of our web root (/blog). What must I include in a file outside of Grav's root in order to access Grav functions?

On our homepage, which is not within the Grav directory, we have a "Recent Blog Posts" widget. I'd like to use Grav syntax to display the 3 latest posts. I assume I can just build a function to dig into the Grav directory and grab the latest pages, but it'd be nice to use Grav's built-in functionality to accomplish this.

9 years ago

Hi there! So, you wish to use Grav functions on non-Grav website? I'm afraid this won't be possible...
But you can rather easy do it via RSS or ATOM feeds perhaps?

👍 1
9 years ago

Without writing an API in a plugin (examples already exist of this), you'd have to parse Grav-generated feeds as MakaryGo suggests or parse files. Those are the only three avenues for obtaining this data.

👍 2
9 years ago

Well, accessing and parsing *.md files shouldn't be programatically complicated but... Perhaps it would be easier to move entire site to grav? 😛

👍 1
9 years ago

Parsing the RSS feed with PHP worked just fine. Thanks for the suggestion @MakaryGo.

9 years ago

@MakaryGo:
Perhaps it would be easier to move entire site to grav?

Ha, I'd love to, but at this point the main site is already too far along to migrate.

9 years ago

Always happy to help 😊

last edited 07/27/17 by Makary

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 50 6 hours ago
Support · by Anna, 2 days ago
2 58 9 hours ago
Support · by Justin Young, 10 hours ago
1 28 10 hours ago
Support · by Duc , 1 week ago
2 63 5 days ago
Support · by Colin Hume, 1 week ago
2 53 5 days ago