Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Access page routes from cli

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

Hi!

I'm using a plugin trough the client command.

I'm trying to get all the routes using this bunch of code:

PHP
$grav = Grav::instance();
$pages = $grav['pages'];
$routes = $pages->routes();

But the routes are always empty, any idea why? If I execute this code on a plugin within the application it works.

Thanks!

10 years ago

To give a bit of context, my idea is to create a pre-cache plugin. I would like to cache the entire application before each deployment, so I would do something like: bin/grav clear-cache and then bin/plugin myPlugin precache.

  • I’m trying to use what has been done on the precache plugin, basically fetching all the routes using $page->content().
  • Using $grav = Grav::instance();, I then start the initialisation using $grav->process();
  • I need to do that before trying to access all the pages routes.
  • But I have an error: E_COMPILE_ERROR - Cannot declare class Grav\Theme\Busuu, because the name is already in use.
  • Busuu is just my current theme.

Anyone has an idea? Thanks!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 673 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5336 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago