Search the Community
Showing results for tags 'save page'.
-
We have a script that synchronizes data from a CSV file on a daily basis. The data that is synchronized all belong to a page type. However, not all data of this type of template is inspected. For example, we have a field called "sku_image" that is manually filled in by the administrator. When there is data to synchronize, the script modifies the relevant fields, then saves the page with the help of a function: protected function savePage(Page $page, $reportErrors = true) { try { $page->setOutputFormatting(false); $page->save(); $page->setOutputFormatting(true); $this->wire('log')->save('centura-synchro', $page->title); } catch(Exception $e) { if($reportErrors) { $this->error($e->getMessage()); $this->wire('log')->save('centura-synchro-errors', $page->title . "=> " . $e->getMessage()); } } return $page; However, for some time now, and we don't know why, the entries in the "sku image" field for saved pages have been systematically deleted from the "field_sku_image" table! The image files remain in each folder, but the reference in the table disappears. The field is a very standard image field and is not processed during synchronization except that when the page object is saved. The other data that is not processed in the synchronization remains in place. It is as if the variable $page forgot the data it is supposed to contain. It's a great mystery. Synchronization is performed with a special "user" who has editing rights for these pages. What could cause such behaviour?
-
Hi, I have a site that has events where the users can make a reservation and something really weird is happening. This is the code: $form = array( 'name' => $sanitizer->text($input->post->name), 'email' => $sanitizer->email($input->post->email), 'phone' => $phone, ); $p = new Page(); $p->template = 'reservation'; $p->parent = wire('pages')->get('/agenda/' . $sanitizer->text($input->post->page_target) . '/'); $p->name = microtime(); $p->title = $form['name']; $p->save(); // CODE TO SEND EMAIL BELOW The user path is: 1. User fills the form with name, email, phone and some more information. 2. Form is validated to see if every information is ok. 3. Information is saved into a new page (reservation template). 4. Send email to user. Everything works fine except in one case: When the same user fills the same form more than once (to add reserves for one or more friends), usually using the same number and email, the friend's name is not filled in the "title" field. This seems to be the only field that fails, it shows empty on the backoffice. However, the email sent to the user has the name (using the same $form['name'] variable). Am I missing something?