Do something after saving?

I’m trying to get all posts to be auto-posted to Facebook once they’re created. I’ve got the Facebook side of it sorted via their SDK, but I can’t seem to find where to put this code to work with the panel?

Ideally I don’t want to edit the core Kirby files but I get the feeling I’m going to have to, I just can’t seem to find which file I need to edit.

If anyone can nudge me in the right direction that would be great, cheers!

I’m afraid that this is not possible without changing the panel core files atm.
The panel isn’t supporting hooks yet.

What about using a service like instead?

I’m using a custom sort of invisible field to create thumbnails after save, maybe you can use that. It’s probably not the most elegant solution but for now and I think until Kirby gets hooks it works.


class ThumberField extends BaseField {

  public function template() {
    //echo $this->page()->uri();
    //return $this->page()->images();
    if ($this->page()->hasImages()) {
      foreach($this->page()->images() as $thumb) {
        if ((!preg_match("/thumb-/i", $thumb->name()))) {
          //echo $thumb->file;
          $tpath = str_replace($thumb->filename(),'',$thumb->root());
          $turl = str_replace($thumb->url(),'',$thumb->root());
          //echo $tpath;
          thumb($thumb, array('filename' => 'thumb-'.$thumb->filename(), 'width' => 200, 'root' => $tpath, 'url' => $turl, 'crop' => true), false);


Oh and at the bottom of a blueprint:

label: Thumber
type: thumber

Thanks all for the replies! I’ve actually ended up doing this a completely different way now.

Basically posts are posted on the site and to Facebook every hour so what I’ve done is create a hidden page that grabs the current time, compares it to a timestamp created from the date and time fields, and then if that time has passed make the post visible and send it to Facebook. I then use CRON to run this code every hour.

I’m sure there is a much better way of doing it, but it seems to be doing the trick for now! It’s actually worked out better than my original idea, as you can now edit the post right up until it goes live and I can schedule as much into the future as I need to!