Jump to content

[solved] adding virtual (non saved) pages to pageArray?


gunter
 Share

Recommended Posts

$calendarPageArray = pages->find($selector);
$p = new Page(); // create new page object
//some page stuff...
$calendarPageArray->add($p);

I found out that it doesn´t seem to be possible to add an unsaved page to the pagearray...
It´s  for a worktime scheduling calendar... a have some real pages with the weekdays and their worktime... and I have also pages with special calendar days with special worktime.. I want get the calendar days from the pagetree into a pagearray... and then adding the generic weekdays as somehow virtual unsaved pages into that pagearray...

 

 

Link to comment
Share on other sites

    $days = 20;    
    $selector = "template=basic-page";
    $resultPageArray = $this->pages->find($selector);
for($i=0;$i<=$days;$i++){
    $p= new Page();
    $p->template = 'basic-page'; // set template
    $p->title = rand();
    $p->name = "virtual-page".rand();
    $resultPageArray->add( $p);
}
d($resultPageArray);

the dumping function is very useful!
Unfortunately I have a problem, this code should in my opionion add 20 pages to items... but only one page gets added, the rest are under $resultPageArray->itemsAdded

image.png.925e8b2833cbe7d1b5da31978300d704.png

 

 

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