Skip to content
Grav 2.0 is officially stable. Read the announcement →
Plugins

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 · 608 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 Vladimir Novak, 2 weeks ago
3 295 2 weeks ago
Plugins · by Mathieu Lecouturier, 3 weeks ago
3 277 3 weeks ago
Plugins · by Slebeig, 2 months ago
1 403 2 months ago
Plugins · by Rene, 2 months ago
2 574 2 months ago
Plugins · by Xavier, 3 months ago
2 490 3 months ago