What is passed to my page template when the CMS is viewing a page that allows the template to know you want to view a different version (perhaps thus far unpublished) of the page?
Is there any way I can replicate this? At the moment, I'm capturing the URL before passing it to a third party template. The RawURL looks like this:
Now I know that 616 is my pageId. What's 7471? Is that a version? Can I fetch this version of the page programmatically?
Yes 7471 is the version id of the page 616. If you check the PageLink property of the page you should see that the ID is 616 and the WorkID is 7471. One way to fetch that specific version of the page is:
PageData page = DataFactory.Instance.GetPage(new PageReference("616_7471"));
Per GunsarfsEPiServer CMS development team