Jump to content

Illegal offset error when trying to edit page through API


thetuningspoon
 Share

Recommended Posts

I am trying to edit a page through the API. I can echo fields from the page and I can perform the save() function, but if I try to make changes to the page first, it gives me a bunch of illegal offset errors like this:

Warning: Illegal offset type in isset or empty in /opt/disk1/www/mywebsite.com/wire/core/Data.php on line 41

Here is my code:

    $my_page = $pages->get($my_page_id);

    $my_page->setOutputFormatting(false);
    $my_page->time_field = time();
    $my_page->removeStatus(Page::statusUnpublished);
    echo "page title: " . $order->title ."\n"; // this works
    $my_page->save(); // fails
 
 
Any ideas? Thanks in advance.
Link to comment
Share on other sites

I don't think "time_field" is valid. Does the following work as is? ie, does it change remove the unpublished status?

    $my_page = $pages->get($my_page_id);

    $my_page->setOutputFormatting(false);
    $my_page->removeStatus(Page::statusUnpublished);
    $my_page->save();
 

What does:

echo $my_page->id
 

return?

Are you sure that $my_page_id is set correctly?

Link to comment
Share on other sites

$my_page->id gives me "1649", which looks like a proper page id to me.

$time_field is just a field on the page. (It's not even actually called that in my program).

I can't even do $my_page->removeStatus(Page::statusUnpublished);  without getting the errors.

Link to comment
Share on other sites

Ok, not really sure what to suggest now - might need someone morre experienced with PW to step in, but when you say you can save the page so long as you don't make any changes, are you sure the page is saving? Is the modified field being updated? Can you make any other changes to the page, like change the body or other simple field? 

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...