Created
December 17, 2016 21:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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