Microsoft Content Management Server - Retrieve preview content from posting

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > November 2004 > Retrieve preview content from posting





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Retrieve preview content from posting
J. C. Loab

2004-11-22, 5:48 pm

Hello,

I'm posting here because I have a problem with my CMS site.
I try to get the content from a preview posting but I don't succeed on it
....
I can get the published version but not the modified one ...

For example, I did :
private void Page_Load(object sender, EventArgs e)

{
Posting p = CmsHttpContext.Current.Posting;

if (WebAuthorContext.Current.Mode == WebAuthorContextMode.AuthoringPreview)
{
CmsApplicationContext cmsContext = new CmsApplicationContext();
WindowsIdentity ident = HttpContext.Current.User.Identity as
WindowsIdentity;
cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);

Posting tempPosting = (Posting)cmsContext.Searches.GetByGuid(p.Guid);
String foo =
((HtmlPlaceholder)tempPosting.Placeholders["Description"]).Html;

this.titleLabel.Text= foo;
}



Do you have any idea to solve my issue ??

Thanks in advance,

JC


Stefan [MSFT]

2004-11-22, 5:48 pm

Hi JC,

that is nt possible this way.
Authoring preview means that the content is not yet saved.
And when you create a new context then you will retrieve the content from
the database - where the change has not yet been saved.
You need to use the CmsHttpContext to retrieve the values and not the
CmsApplicationContext.
In AuthoringPreview you should get the content just edited.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"J. C. Loab" <psykotick@gmail.com> wrote in message
news:uojUfWJ0EHA.1332@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I'm posting here because I have a problem with my CMS site.
> I try to get the content from a preview posting but I don't succeed on it
> ...
> I can get the published version but not the modified one ...
>
> For example, I did :
> private void Page_Load(object sender, EventArgs e)
>
> {
> Posting p = CmsHttpContext.Current.Posting;
>
> if (WebAuthorContext.Current.Mode ==

WebAuthorContextMode.AuthoringPreview)
> {
> CmsApplicationContext cmsContext = new CmsApplicationContext();
> WindowsIdentity ident = HttpContext.Current.User.Identity as
> WindowsIdentity;
> cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);
>
> Posting tempPosting = (Posting)cmsContext.Searches.GetByGuid(p.Guid);
> String foo =
> ((HtmlPlaceholder)tempPosting.Placeholders["Description"]).Html;
>
> this.titleLabel.Text= foo;
> }
>
>
>
> Do you have any idea to solve my issue ??
>
> Thanks in advance,
>
> JC
>
>



J. C. Loab

2004-11-23, 2:47 am

Thanks Stefan for your answear but I still have a problem.

Using CmsHttpContext, I still get the old published posting and not the
modified one ..
My code is the following :

Posting tempPosting = CmsHttpContext.Current.Posting;
String foo =
((HtmlPlaceholder)tempPosting.Placeholders["Description"]).Html;

Please, can you help me a bit ?



Thanks in advance !!!



JC



"Stefan [MSFT]" <stefang@online.microsoft.com> a écrit dans le message de
news:u%23%23YGUL0EHA.2316@TK2MSFTNGP15.phx.gbl...
> Hi JC,
>
> that is nt possible this way.
> Authoring preview means that the content is not yet saved.
> And when you create a new context then you will retrieve the content from
> the database - where the change has not yet been saved.
> You need to use the CmsHttpContext to retrieve the values and not the
> CmsApplicationContext.
> In AuthoringPreview you should get the content just edited.
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>
> MCMS FAQ:
>

http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
>

http://www.gotdotnet.com/community/...t+S
erver

> MCMS Whitepapers and other docs:
> http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
> --------------------------------
>
>
> "J. C. Loab" <psykotick@gmail.com> wrote in message
> news:uojUfWJ0EHA.1332@TK2MSFTNGP10.phx.gbl...
it[vbcol=seagreen]
> WebAuthorContextMode.AuthoringPreview)
cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);[vbcol=seagreen]
>
>



Angus Logan [MVP]

2004-11-23, 2:47 am

Hi JC,

What is the actual problem? (is an error being raised or are you getting no
results?)

Regards
--
________________________________________


Angus Logan (MCAD/MCDBA/MCP/MVP for MCMS)
Product Specialist
Microsoft Application Solutions
Data#3 Limited
E angus_logan@data3.com.au
BLOG www.anguslogan.com
________________________________________

"J. C. Loab" <psykotick@gmail.com> wrote in message
news:%23wVUakT0EHA.3808@tk2msftngp13.phx.gbl...
> Thanks Stefan for your answear but I still have a problem.
>
> Using CmsHttpContext, I still get the old published posting and not the
> modified one ..
> My code is the following :
>
> Posting tempPosting = CmsHttpContext.Current.Posting;
> String foo =
> ((HtmlPlaceholder)tempPosting.Placeholders["Description"]).Html;
>
> Please, can you help me a bit ?
>
>
>
> Thanks in advance !!!
>
>
>
> JC
>
>
>
> "Stefan [MSFT]" <stefang@online.microsoft.com> a écrit dans le message de
> news:u%23%23YGUL0EHA.2316@TK2MSFTNGP15.phx.gbl...
> rights.
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> http://www.gotdotnet.com/community/...t+S
erver

> it
> cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);
>
>



J. C. Loab

2004-11-23, 5:56 pm

Hello Angus,

My problem is that I get the published content and no the modify one.
No error is raised but I don't know if my request is goood.

When I look at the posting property from CmsHttpContext.Current.Posting,
for example status is "Published".

What I want to do is quite simple (I hope).

I've got a base page where I load dynamically control depending if I'm in
edit or live mode.
This work fine.

When I'm in edit mode, I click the preview link and I want to display to
modifyed content => The basepage is load and I put my viewer control. I
choose this design because I want that preview reflect real page !!

Thanks in advance !

JC



This is part of my code :

PageBase.aspx.cs
--------------------
Control c = null;
if (! CmsState.IsEditSite())
{
c = LoadControl("Controls\\ViewControl.ascx");
c.EnableViewState = false;
}
else
{
c = LoadControl("Controls\\EditControl.ascx");
}
this.mainPlaceholder.Controls.Add(c);



ViewControl.ascx.cs
-------------------------------------------

if (WebAuthorContext.Current.Mode == WebAuthorContextMode.AuthoringPreview)
{
Posting p = CmsHttpContext.Current.Posting;
Posting tempPosting = CmsHttpContext.Current.Posting;
String foo = ((HtmlPlaceholder)tempPosting.Placeholders["Title"]).Html;
this.titleLabel.Text= foo;
}
else
{
this.titleLabel.Text = ((HtmlPlaceholder)
p.Placeholders["titre"]).FilteredHtml;
}







"Angus Logan [MVP]" <angus_logan@data3.com.au> a écrit dans le message de
news:u8lqaDU0EHA.1392@tk2msftngp13.phx.gbl...
> Hi JC,
>
> What is the actual problem? (is an error being raised or are you getting

no
> results?)
>
> Regards
> --
> ________________________________________

>
> Angus Logan (MCAD/MCDBA/MCP/MVP for MCMS)
> Product Specialist
> Microsoft Application Solutions
> Data#3 Limited
> E angus_logan@data3.com.au
> BLOG www.anguslogan.com
> ________________________________________

> "J. C. Loab" <psykotick@gmail.com> wrote in message
> news:%23wVUakT0EHA.3808@tk2msftngp13.phx.gbl...
de[vbcol=seagreen]
from[vbcol=seagreen]
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm[vbcol=seagreen]
http://www.gotdotnet.com/community/...t+S
erver
[vbcol=seagreen]
on[vbcol=seagreen]
cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);[vbcol=seagreen]
>
>



Stefan [MSFT]

2004-11-24, 7:52 am

Hm... that sounds strange.
I would need to repro this.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"J. C. Loab" <psykotick@gmail.com> wrote in message
news:#wVUakT0EHA.3808@tk2msftngp13.phx.gbl...
> Thanks Stefan for your answear but I still have a problem.
>
> Using CmsHttpContext, I still get the old published posting and not the
> modified one ..
> My code is the following :
>
> Posting tempPosting = CmsHttpContext.Current.Posting;
> String foo =
> ((HtmlPlaceholder)tempPosting.Placeholders["Description"]).Html;
>
> Please, can you help me a bit ?
>
>
>
> Thanks in advance !!!
>
>
>
> JC
>
>
>
> "Stefan [MSFT]" <stefang@online.microsoft.com> a écrit dans le message de
> news:u%23%23YGUL0EHA.2316@TK2MSFTNGP15.phx.gbl...
from[vbcol=seagreen]
> rights.
>

http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
>

http://www.gotdotnet.com/community/...t+S
erver

> it
> cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com