Jump to content

applab

Members
  • Posts

    36
  • Joined

  • Last visited

Community Answers

  1. applab's post in Is It Possible To Add A 'comment' Programmatically? was marked as the answer   
    thanks Teppo, worked great after 1 amendment:
    on first attempt I got an error:
    "Error: Exception: Can't save field from page 1028: /blog/posts/test-post/: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved."
    so, I did as the error suggested end ended up with:
    $comment = new Comment; $comment->text = "my text"; $comment->cite = "my name"; // etc. $p = $pages->get('/about/'); $p->setOutputFormatting(false); // added $p->comments->add($comment); $p->save('comments'); checking the PW cheatsheet for $page->setOutputFormatting() makes it clear why that's needed.
×
×
  • Create New...