Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Community Answers

  1. onjegolders's post in Trouble Detecting if there are siblings to a page or not was marked as the answer   
    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); ?>
  2. onjegolders's post in Updating Session data via jQuery post was marked as the answer   
    Seems I didn't pay attention to the syntax
    $session->$mysession = "Whatever";
    I'd assumed that second $ was inferred.
  3. onjegolders's post in Redirect to front-end on page save was marked as the answer   
    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); } } }
  • Create New...