Jump to content

bekasa

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by bekasa

  1. Thank you for your replies that clarifies the situation completely. Processwire is genius but equally it's forum contributors.
  2. Hi, This question relates to finding the page id after a new page has been saved. A new page is generated as in the code below. $p = new Page(); $p->template = 'page_template'; $p->parent = wire("pages")->get(parent_id); $p->addStatus(Page::statusUnpublished); $p->field = $something; /*set more fields*/ $p->save(); Straightforward, but because the new page has fields which include page reference fields it has to be saved at this stage then further page reference fields added . Again straightforward and page reference fields can be added. $p->reference_field = $something; $p->reference_field->save(); This works without a hitch, after the first $p->save() operation, the $p->id (the page id ie of the new page just saved to disc) becomes available. It seems that $p has changed from referencing an in memory object (new page) to an actual page (on disc). I thought I would have to execute a 'find' operation to discover the new page just saved to actually acquire the stored $page reference to continue editing. Has anyone an explanation of how this change in referencing takes place? I was concerned about this because there is the possibility that numerous pages could be added at the same time and that it may not be 'safe' to rely on $p as being the $page reference even though it seems to work. Thanks in advance and to all forum contributors
×
×
  • Create New...