michel v
-
Posts
3 -
Joined
-
Last visited
Posts posted by michel v
-
-
Hi!
After adding a page with $pages->add(), the value of the returned page object's "created" property is always 0. I thought it would give me the timestamp of when the page was created.
In the admin, I can see that the page has been added and that the created/modified times are correct.
$testPage = $pages->add('basic-page', '/', [ 'title' => 'This is the page title', 'body' => 'Lorem ipsum' ]); var_dump($testPage->title); // result: "This is the page title" var_dump($testPage->created); // result: 0
Is there a way to get the correct timestamp after adding a page with the API?
Thanks!
-
Cannot get 'created' value after pages->add
in API & Templates
Posted
Thanks for the welcome ?
Basically, I want to compare the "created" timestamp of the new page with the "created" timestamp of another page.
I have since found out that I can do it by calling $pages->get() with the id of the newly created page:
I don't really understand why I can't get at it directly though. If $testPage has an id, I would think it has been saved to the database, and all fields would be populated. But hey, whatever works ?