Jump to content

jncs

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

jncs's Achievements

Newbie

Newbie (2/6)

0

Reputation

  1. Ok i don't now what is going wrong, but i seems to be some things i have installed, i need to test this longer, thanks a lot.
  2. Hi @Edison, thank you for your efford, The Session is not manipulated at this point, it is saved from a form much earlier and not touched again. I think the Problem ist: $page wire('pages')->find($page->id)[0] Isn't the same object, not after "Page::saved" nor after "Page:save". Also wire('pages')->uncacheAll(); Has no effect. Have you an Idea where i can hook after a page is saved and it is realy saved?
  3. Hi @Edison, thank you for your replay. Here my Code, (a little shortend). public function init() { $this->addHookAfter('Pages::saveReady', $this, 'doStuffBeforeOrderIsSaved'); $this->addHookAfter('Pages::saved', $this, 'doStuffAfterOrderIsSaved'); } function doStuffBeforeOrderIsSaved($event) { $page = $event->arguments('page'); if($page->template != "my_template") return; if($page->isUnpublished()) return; bd($page, "Datenübername"); if($this->session->get("email") != null) $this->addAdressAndName($page); } function addAdressAndName($page){ $page->of(false); $page->email = $this->session->get("email"); // etc.... } function doStuffAfterOrderIsSaved($event) { $page = $event->arguments('page'); $changes = $event->arguments('changes'); if($page->template != "my_template") return; if($page->isUnpublished()) return; if(array_key_exists('customer_status',$changes)) { $this->sendMail($this->message, $page); } } public function sendMail($message,$page) { bd($page,"object from event"); bd(wire('pages')->find($page->id)[0],"object from find"); $mail = wireMail(); $hanna = wire('modules')->get('TextformatterHannaCode'); $hanna->page = $page; $subject = $message->message_header; $bcc = $message->message_bcc; $from = $message->message_from; $text = $hanna->render($message->message_text,$page); $mail->to($page->email); $mail->bcc($bcc); $mail->from($from); $mail->subject($subject); $mail->bodyHTML($text); $mail->body(strip_tags($text)); $mail->send(); } In sendMail Hanna Code gets not the freshly Saved Object, but the old one, without the updatet Data. Also $page->email is not the updated one. But in the Output from tracy the first page object seems to be right. It Only apperes if the data is updatet via doStuffBeforeOrderIsSaved and then used in doStuffAfterOrderIsSaved. Is this an caching Problem? Can i get arround this by invalading the cache for this object, and how to do that? Thanks a lot.
  4. Hi everyone, i tried a little bit with hooks. I Update a Page in Pages::saveReady and Try to do Stuff with Hanna Code in Pages::saved I realized that. the $page Object is the Problem cause of: $page $page2 = wire('pages')->find($page->id)[0], Are in the Hook Method ( After Pages::saved) not the same. Why is this so? And how i can get arround this? (Version 3.0.98) Thanks a lot jncs
×
×
  • Create New...