Jump to content

$pages->add() bug?


pwFoo
 Share

Recommended Posts

I tried to add a new page with $pages->add() with a custom method inside of a module. It looks like the method is called each page load (as should) and also if the backend page tree is loaded / refreshed (bug??)?

    public function create($template, $parent, Array $data = array(), $name = false) {
        $name = wire('sanitizer')->pageName($name ? $name : $data['title']);
        $obj = wire('pages')->add($template, $parent, $name, $data);
        return $obj;
    }

called inside of home page ("/"):

$api->create('basic-page', '/', array('title' => 'ApiCreatedTest1'));

Works fine. Load it twice (create duplicate page) results in an error.

 

But without "/" requested the page gets created if I view the backend?!

Checked it by delete the page, check the page tree again and it looks fine. But if I reload the backend page the page appears again. So backend page tree load executes the home page ("/") and create the page?

Is it a bug or I'm missing anything...?

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

×
×
  • Create New...