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

Access page routes from cli

Started by Muut Archive 9 years ago · 3 replies · 545 views
9 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!

9 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 Deleted User, 9 years ago
0 1336 9 years ago
Archive · by Muut Archive, 9 years ago
2 926 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2941 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago