I have a lot of pages in a site generated by a conversion from typo3. Now I want to improve custom settings and taxonomy in the frontmatter of a large subset of these pages.
Do you have any tool suggestion beside sed to batch edit the custom headers? For example I have to move a field from a custom header to taxonomy. Anyone who did similar operations and can give me hints?
I’ve automized operations in some contexts using events. To give you an idea:
$page = $pagesobj->get($pathtopage);
if ($page) {
if (isset($page->header()->filterforme)) {
$page->modifyHeader('whatever', false);
$page->save();
}
}
Everything you need is available in the Pages and the Page class. The admin plugin has several event hooks that you may use to execute bulk routines: onAdminAfterSave, onAdminSave but you can use as well the onPagesInitialized event.
Interesting, it’s all there, right. Thank you for that. I’am not a php-lover coming from java and unnaturally try to avoid it, but without a real reason. I will read the API pages of the events and the modification calls. Where should I place that code? Would it be in a plugin or elsewhere?
For things related with your site only you can use the theme.php file, that’s one possibility, or you prepare a re-usable plugin for your bulk edits to have it at hand in the future. Grav offers good documentation and it’s in fact quite easy if you have some basic knowledge.