Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Plugin: do something onAdminSave, but only if folder isn't being moved

Solved by Anna View solution

Started by Anna 7 years ago · 1 replies · 633 views
7 years ago

Hey everybody,

I have a tiny bit of custom admin processing for pages with a certain template. All is working fine so far, but not when the page's folder is being renamed, because I'm checking whether a certain file exists under that route.

My problem here is that I don't know how to say "don't do this if folder is being moved (renamed)". When I dump($event['object']) after a folder rename, I can find an action "move" at the end of a long list of Page details:

TXT
Page {#300 ▼
  [lots of stuff goes here]
  #debugger: null
  #forms: null
  -_original: Page {#254 ▶}
  -_action: "move"
  #media: null
}

But how do I check this private property? I'm sure I'm missing something simple here…

Thanks for your time!

7 years ago Solution

I still do not know the answer to this, but I actually found a better solution. So far I have been doing the custom processing bit in the event onAdminSave, and now I simply moved it under onAdminAfterSave. By then the folder has already been renamed and everything just works fine. 🙂

Suggested topics

Topic Participants Replies Views Activity
Plugins · by complanar, 2 weeks ago
2 255 4 days ago
Plugins · by Vladimir Novak, 1 month ago
3 595 1 month ago
Plugins · by Mathieu Lecouturier, 2 months ago
3 417 2 months ago
Plugins · by Slebeig, 2 months ago
1 530 2 months ago
Plugins · by Rene, 3 months ago
2 732 3 months ago