simonsays

Starter
  • Content count

    20
  • Joined

  • Last visited

Community Reputation

0 Neutral

About simonsays

  • Rank
    Jr. Member

Recent Profile Visitors

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

  1. simonsays

    Weird, failed first 2 times, but works perfectly now. Logs did not find anything. Guess, something with my localhost...
  2. simonsays

    The problem was actually with apache virtual host (the <Directory> was not specified). Thanks for your patience and cooperation!
  3. simonsays

    So, what you are saying, is PW's .htaccess should work out of the box? I did not change anything in .htaccess. I assume, the problem is somewhere in apache vhost, where I do not have admin access.
  4. simonsays

    yes, that is my question
  5. simonsays

    Seen this thread, it is irrelevant to my problem as I have already input httpHost value with port in it. It is URL being inproperly rewritten.
  6. Hello, I have recently finished local development with ProcessWire and moved to DEV VPS. However, DEV VPS base url has port number in it. url:port. So, when I either go to admin url:port/processwire and or any of the subpages, they are not found. Do I need to modify anything in .htaccess or Apache? Does anyone have experience with this?
  7. simonsays

    @LostKobrakai When I try to install module using your migration, extra permission declared for this module in getModuleInfo() is not installed automatically. When I install module via admin, permission is added OK. Is this a bug? Or was it done like that intentionally?
  8. simonsays

    Okay, found a workaround of assigning title to $original (without saving). That way it worked. Doesn't it feel to be a bit off?
  9. simonsays

    protected function copy() { $input = $this->wire('input'); $id = $this->wire('sanitizer')->int($input->post->id); $original = ($id) ? $this->wire('pages')->get($id) : $this->wire('page'); $redirect = $this->wire('page')->path; if ($this->canEdit() && $original) { $original->of(false); $copy = $this->wire('pages')->clone($original, null, false); $copy->title .= ' - Copy'; $copy->save(); if ($original->hasChildren()) { $children = $original->children('include=all'); foreach ($children AS $child) { $this->copyChild($child, $copy); } } $this->sc->flash->success('Page "' . $original->title . '" successfully copied as "' . $copy->title . '"'); $templateTags = array_map('strtolower', explode(' ', $original->template->tags)); if (!in_array('section', $templateTags)) { $redirect = $copy->path; } } $this->wire('session')->redirect($redirect); } Bump! I was still unable to solve the problem. I now have a copy method, which does not use setDummyData and has 100% same problem. Every time a save is performed, image is reset. When I comment out $copy->save(); the image is preserved. Does anyone know a workaround?
  10. simonsays

    Like I said, I do not receive an error (know, that page must exists before files are attached), I simply get an empty image. So, I added $page->save() to savePageBasic() (thanks for the optimization advice) to make sure page ID exists by the time image is added public function savePageBasic() { $input = $this->wire('input'); $page = $this->wire('page'); $sanitizer = $this->wire('sanitizer'); if ($input->post->submit && $this->canEdit()) { $p = new Page(); $parent = $page->path; $p->parent = $parent; $p->template = $sanitizer->text($this->input->post->section); $p->addStatus(Page::statusUnpublished); $p->title = $sanitizer->text($input->post->title); $p->save(); return $p; } return false; } The submit() method remained the same public function submit() { $input = $this->wire('input'); $page = $this->wire('page'); $session = $this->wire('session'); if ($input->post->submit && $this->canEdit()) { if (($p = $this->savePageBasic()) !== false) { $p->addStatus(Page::statusHidden); $this->setDummyData($p); $p->save(); $this->sc->flash->success('Page "' . $p->title . '" successfully saved'); } $session->redirect($page->path); } } $p->save() reset the image somehow (commenting it out solves the issue). But that is extremely wrong IMHO.
  11. simonsays

    Like I wrote, the image is saved as long as I do not run $page->save() after running setDummyData(). I do not understand, why it empties the image field.
  12. Hello everyone, I have two methods inside a class public function savePageBasic() { $input = $this->wire('input'); $page = $this->wire('page'); $sanitizer = $this->wire('sanitizer'); if ($input->post->submit && $this->canEdit()) { $p = new Page(); $parent = $this->wire('pages')->get($page->path); $p->parent = $parent; $p->template = $sanitizer->text($this->input->post->section); $p->name = $sanitizer->pageName($input->post->title); $p->addStatus(Page::statusUnpublished); $p->title = $sanitizer->text($input->post->title); return $p; } return false; } public function submit() { $input = $this->wire('input'); $page = $this->wire('page'); $session = $this->wire('session'); if ($input->post->submit && $this->canEdit()) { if (($p = $this->savePageBasic()) !== false) { $p->addStatus(Page::statusHidden); $this->setDummyData($p); $p->save(); } $session->redirect($page->path); } } /** * Set dummy data to page fields */ protected function setDummyData(&$page) { $dummyData = [ 'FieldtypeTextareaLanguage' => 'Start writing your <b>%s</b> here...<br/>Make sure text is input before you publish...', 'FieldtypeImage' => 'https://dummyimage.com/1200x900/c2c2c2/2e2e2e.png&text=No+image+yet', ]; foreach ($page->template->fields AS $field) { $type = (string)$field->type; if (isset($dummyData[$type])) { $value = sprintf($dummyData[$type], strtolower($field->label)); $page->{$field->name} = $value; $page->save(); } } return true; } I have a page with textarea and single image and a method which sets some dummy data to them. The problem is, that after running $page->save() inside submit() method, image disappears (text stays). Commenting $page->save out of submit() method solves the issue, but this is wrong in my opinion as I might want to have some manipulations after dummy data is set. I checked the output formatting and it stays false throughout the entire cycle. What could be the problem?
  13. simonsays

    Good stuff, thanks for the update!
  14. simonsays

    Awesome, thanks @LostKobrakai! Saved me a lot of effort and I also became slightly smarter in the process ;)
  15. simonsays

    Hello! Thanks for the wonderful module! Does anyone know, how to use it for FieldtypeOptions? Like picking the type (single or multiple) and setting options values. My attempts for this have failed so far. @LostKobrakai