So I’ve gotten the hook activating but ran into a few issues.
Here’s is where the hook started, but this threw a few errors my way:
<?php
kirby()->hook('panel.page.create', function($page) {
if($page->isChildOf(template('series_visual'))) {
$newPage = $page;
}
// this is the page which has the structure field type
$seriespage = $page()->parent();
// add a new entry to the array
$dateupdate[] = ['sortdate' => $newPage->date()];
// update the structure field type
$seriespage->update(yaml::encode($dateupdate));
});
And my blueprint code is currently this:
sortdate:
label: Most Recent Date
type: structure
I initially set the field to be date but it told me that was reserved so I switched the field to be sortdate.
Once I then created a new page under a page with the ‘series_visual’ template it threw me an error that the childOf couldn’t be a template - I am hoping to do this whenever I create a new child of any page that has that template rather than a specific page.
I changed that to be just page specific and I’m getting this error when I try to create a new subpage:
Call to a member function id() on boolean in file: /nfs/c01/h03/mnt/11800/domains/test.randy-gibson.com/html/kirby/core/page.php on line: 807
If I switch the hook to be panel.page.update I get the same error when I try to save the subpage.
I’m sure there’s a myriad of things wrong with this, but I couldn’t find any solid documentation of the methodologies for these hooks so I’m working from this post: Kirby 2.1 Hook Usage- Creating Subpages
Many thanks for any help figuring this out!!