Jump to content

How to move pagefile to a different page via API?


hellomoto
 Share

Recommended Posts

This did not work...

                $np = new Page();
                $np->parent = $page;
                $np->template = 'upload';
                $np->title = 'tmp';
                $np->save();
                $np->of(false);
                $np->uploaded->add($f);
                $np->title = $f->basename;//$t->description;
                $np->name = $sanitizer->name($np->title);
                $np->save();
                $this->message('Uploaded to new page: '.$np->title);

                wire('pagefiles')->delete($f);

Error: Call to a member function add() on null

Edited by hellomoto
Link to comment
Share on other sites


                $np = new Page();
                $np->of(false);
                $np->parent = $page->id;
                $np->template = $make;
                $np->title = 'tmp';
                $np->addStatus('unpublished');
                $np->save();
                $np->uploaded->add($f);
                $np->title = $f->basename;
                $np->save();
                $this->message('Uploaded to new page '.$np->id.': '.$np->title);

                $page->upload->delete($f);
                $page->save(['noHooks' => true]);

works

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...