Q (or bug report): Why do all the links here (https://docs.silverstripe.org/en/4/lessons/) in the ToC go to a page (e.g. http://www.silverstripe.org/learn/lessons/creating-your-first-theme) but then all redirect to https://www.silverstripe.org/learn/lessons/v4/ ? (edited)

Attachments:
silverstripe.org  
Lessons
silverstripe.org  
Lessons

p.s. whatever you return from the closure is also subsequently returned from the whileDraft() helper function. (edited)

I just like to use closures to wrap your code and let the function do the heavy lifting of cleaning up after you

so the final code is a little simpler (easier to read, at least):

  1. // ... doing stuff in whatever current stage is...
  2.  
  3. $page = whileDraft(function() {
  4. // This definitely needs to be in draft, no matter what.
  5. return Page::get()->byID(123); // or as you prefer, Page::get_by_id(123)
  6. });
  7.  
  8. // ... continue doing your regular thing...

https://en.wikipedia.org/wiki/Separation_of_concerns (edited)

Attachments:
  
Wikipedia

that's why I just say "F it" and use closures and let abstractions do their work

depending on if silverstripe decided to set your session so that subsequent page loads persist the stage choice 😂