Adding custom action button in Panel

Thank You @distantnative and @walkerbox for guidelines!

But figured out a bit different way - so got it work. My approach:

  1. Added file “site\fields\action\action.php” (which is copy of panel\app\fields\info\info.php)
  2. Inside action.php changed result function, now looks like this:
public function result() {
    $url = 'http://' . $_SERVER['HTTP_HOST'] . '/mysite/api';
    $obj = file_get_contents($url);
    file_put_contents('../../api.json', $obj);
  }

and in bluprint added:

fields:
  action:
    label:
    type: action
    text:

So everytime I something changing in content and push SAVE button afterwards, all content data is saved as JSON.
How to set up JSON export I wrote here: Export all site content as JSON

Why I using such approach with JSON? because I have offline site and don’t want to bother with PHP requests every time. So I have solid data as JSON, but its flexible on every Panel SAVE.

1 Like