Skip to content

Instantly share code, notes, and snippets.

@flokosiol
Created December 17, 2016 21:57
Show Gist options
  • Save flokosiol/2b62f891ebe5047782230708c3207aba to your computer and use it in GitHub Desktop.
Save flokosiol/2b62f891ebe5047782230708c3207aba to your computer and use it in GitHub Desktop.
Reset 'uptodate' flag of all translations if page is saved in default language via kirby panel
<?php
kirby()->hook('panel.page.update', function($page) {
// only trigger if page has default language
if (site()->language()->code() == site()->defaultLanguage()->code()) {
foreach(site()->languages() as $language) {
// don't reset default language itself
if ($language->code() == site()->defaultLanguage()->code()) {
continue;
}
try {
$page->update(array(
'translations' => 0, // change 'translations' to the name of your field
), $language->code());
} catch(Exception $e) {
echo $e->getMessage();
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment