This blog post is inspired by “Shawn”. Hope this helps.
Some background first I think. There are 2 ways to log in to CMS – normal and integrated. An integrated login means that your Windows user account is passed silently by your browser to the CMS server and you don’t need to type in a username or password. If you’re organisation uses Windows and you aren’t using integrated login slap yourself across the face now for being lazy, then read up on how to configure it. Your users will thank you tomorrow. It takes about 10 minutes to set up and is much better for security (since it’s harder to forge). If you are using integrated login already this is super-easy and you’re probably wondering why I’m bothering to blog about this at all. If you’re reading this, therefore, it stands to reason that you’re not.
I am going to assume that you, reader, already has the capabilities required to locate the GUID of the page you want a preview of. In some cases you will require the LinkFromGuid as well to provide CMS with the context it needs to render the page properly. I have had success with the following minimalist URL:
[If you use Action=Preview it will work without the Mode parameter]
[If you have lots of projects you should send the ProjectGuid parameter too]
If you want the full thing for your case simply pop a preview window, right-click the page and hit Properties. Triple-click (yes, you read that right) on the URL to select even the bits that fall off the screen and you can copy/paste into your editor of choice.
There are 3 approaches…
You can use the following RQL to get the preview HTML of a CMS page:
<IODATA loginguid="[LoginGuid]" sessionkey="[SessionKey]"> <PREVIEW mode="0" projectguid="[ProjectGuid]" versionguid="[VersionGuid]" isolated="[Isolated]" generatedate="[AsAtDate]" templateguid="[templateGuid]" rights1="[UserRights]" loginguid="[LoginGuid]" url="[URL]" querystring="[QueryStringParams]" /> </IODATA>
Simply point your user at the URL. Since the browser and RedDot do the login in the background it should just work. Assuming you already have the GUIDs you need from somewhere else. If not, you first need to run some RQL to get them. This is where the Integrated Login plugin I talked about before comes in handy. Using that you can silently log your user into RQL, execute whatever steps are required to get your GUIDs, and redirect the user to the correct URL. Job done.
The problem here is that you need to get credentials off your user. If you don’t log your session in to RedDot you will get a nasty error message when you launch the preview URL to the effect that LogonGuid and SessionKey are missing. That’s because these are server variables that RedDot is expecting to have when it attempts to generate the preview. The only way forward is to get them, and that means logging in.
You need to do this in ASP because we need to set Session variables for the CMS to use. It is possible to get/set session variables with other languages but it’s way harder than if you just use ASP. Here are the steps to follow:
The reason we do it as a plugin is that plugins run within the application scope of the CMS. That means session data stored in a plug is available to the main CMS, including the LogonGuid and SessionKey that get generated as part of the RQL login process. We can save these to Session variables so the preview page can get at them.
No related posts.