I think page->siblings() returns the current page as well (not sure why)
So may have to do something like this (untested)
<?php $siblings = $page->siblings()->remove($page); ?>
Update, thanks Reno, I've got it working now, not sure entirely what wasn't working before but now it's doing the job
Below the code in case it helps someone at a later date
<?php
class BlogRedirect extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'Redirects back to front end journal',
'version' => 101,
'summary' => 'Redirects back to front end journal page.',
'singular' => true,
'autoload' => true,
);
}
public function init() {
$this->pages->addHookAfter('save', $this, 'redirect');
$this->pages->addHookAfter('trash', $this, 'redirect');
$this->pages->addHookAfter('trashed', $this, 'redirect');
}
public function redirect($event){
$page = $event->arguments(0);
$errors = false;
// check notices for errors before redirecting
foreach(wire('notices') as $notice){
if($notice instanceof NoticeError) $errors = true;
}
// if errors
if ($errors) {
return;
}
// if no created date is set it means just generated so don't redirect
if ($page->created == 0) {
return;
}
// set return URL
$goto = wire("pages")->get("template=journal")->url;
// if it's one of the chosen templates, redirect
if ($page->template == "blog_post" || $page->template == "gallery_post"){
wire("session")->redirect($goto);
}
}
}