Jump to content

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


Recommended Posts

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

 

 

Posted

Yep d() for dumping to the current output (either the console results or the template file where you call it from), or bd() for bardump which dumps to a dedicated Dumps panel on the Tracy debug bar.

Posted
    $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

 

 

Posted


problem solved! I have to set a unique id -> then the code from my last posting works - without setting the id -> just one page (the last one) is getting added to the page array

    $p->id = rand();

 

  • Like 2

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...