I created a plugin with the createIndexData function:
public static function createIndexData($file): bool
{
$pages = self::getPages();
$grav = Grav::instance();
if($pages !== null){
$locator = $grav['locator'];
$grav['twig']->twig_paths[]= array_merge(Grav::instance()['twig']->twig_paths, $locator->findResources('theme://templates'));
$grav->fireEvent('onTwigTemplatePaths');
$page = $pages->find('/austria/_price-list');
/*dump($page);*/
dump($page->content());
exit();
}
return false;
}
The plugin is called in onPagesInitialized. I just need to get the processed content from the modular page. In the modular page, I include content from another page: (/pages/austria/_price-list)
{% set moduleName= 'price-list' %}
{% set pageUrl = page.find(uri.path).rawRoute[1:] %}
{% set pageUrl = '/global-variables-and-templates/price-list/data/_austria' %}
{% set page = page.find(pageUrl) %}
{% if not page %}
PAGE NOT EXIST!!!!<br />url: {{pageUrl}}<br />modul-name: {{moduleName}}
{% else %}
{% include page.template~'.html.twig' with {'content' : page.content} %}
{% endif %}
plugin returns error: Template "modular/price-list-global.html.twig" is not defined. What is wrong? Or how to get the processed content from the modular page in grav in the custom plugin?