Hi,
I have the following hook on page update
kirby()->hook('panel.page.update', function($page) {
try {
if($page->parent()->intendedTemplate()=='year') {
$posts = page('home')->newest();
$postsarray = $posts->yaml();
$postsarray[] = ['post' => $page->uri()];
page('home')->update(array(
'newest' => yaml::encode($postsarray),
));
}
} catch(Exception $e) {
echo $e->getMessage();
}
});
What this basically does: everytime a page is updated the hook will store its URI in an array at the âhomeâ section. This is basically a very simple ânewest postsâ or ârecently edited postsâ section Iâm working on. So, my question is:
- How can I check for duplicate entries and replace them or not save anything if the post is already there?