Microsoft Content Management Server - Retrieve hidden items by code.

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > February 2004 > Retrieve hidden items by code.





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 hidden items by code.
Emmanuel

2004-02-04, 10:46 am

Hi,

I just start to use CMS 2002 and I face off with a problem. May be you
can help me I searched for an answear in the google archive with no
successs !!

Here's my problem : I'm got some items (Posting and Channel) in a
channel that are in "HideWhenPublished" mode. When i trying to
retrieve those items with the Model Object I can't. My piece of code
(below) show me hidden items when I'm on edit site mode but don't show
them on live site mode.

Maybe I miss something.

Thanks in advance for your help.


Regards,
Emmanuel




Code that doesn't work :
-------------------------------------------------------------------------------

CmsApplicationContext appContext = new CmsApplicationContext();

WindowsIdentity ident =
(WindowsIdentity)HttpContext.Current.User.Identity;
appContext.AuthenticateUsingUserHandle(ident.Token,
PublishingMode.Unpublished);
appContext.SessionSettings.AutoFilterHidden = false;

Channel c = CmsHttpContext.Current.Channel;
foreach(Channel sc in c.Channels)
{
this.Literal1.Text += "==>" + sc.Name + "<br>";
}

foreach(Posting sp in c.Postings)
{
this.Literal1.Text += "--><a href=\"" + sp.Url + "\">" + sp.Name +
"</a><br>";
}
Stefan [MSFT]

2004-02-04, 10:46 am

Hi Emmanuel,

hidden when published exactly does this!
It hides hidden items, so it is no wonder that you cannot retrieve them.

You can override this default setting by setting the following property:

SessionSettings.AutoFilterHidden = False;

Be sure to set it back after you used it!

Cheers,
Stefan.

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


"Emmanuel" <Manu_Public@hotmail.com> wrote in message
news:d443b124.0401290446.1d562d44@posting.google.com...
quote:

> Hi,
>
> I just start to use CMS 2002 and I face off with a problem. May be you
> can help me I searched for an answear in the google archive with no
> successs !!
>
> Here's my problem : I'm got some items (Posting and Channel) in a
> channel that are in "HideWhenPublished" mode. When i trying to
> retrieve those items with the Model Object I can't. My piece of code
> (below) show me hidden items when I'm on edit site mode but don't show
> them on live site mode.
>
> Maybe I miss something.
>
> Thanks in advance for your help.
>
>
> Regards,
> Emmanuel
>
>
>
>
> Code that doesn't work :
> --------------------------------------------------------------------------


-----
quote:

>
> CmsApplicationContext appContext = new CmsApplicationContext();
>
> WindowsIdentity ident =
> (WindowsIdentity)HttpContext.Current.User.Identity;
> appContext.AuthenticateUsingUserHandle(ident.Token,
> PublishingMode.Unpublished);
> appContext.SessionSettings.AutoFilterHidden = false;
>
> Channel c = CmsHttpContext.Current.Channel;
> foreach(Channel sc in c.Channels)
> {
> this.Literal1.Text += "==>" + sc.Name + "<br>";
> }
>
> foreach(Posting sp in c.Postings)
> {
> this.Literal1.Text += "--><a href=\"" + sp.Url + "\">" + sp.Name +
> "</a><br>";
> }




=?Utf-8?B?RW1tYW51ZWw=?=

2004-02-04, 10:46 am


Ok I feel stupid now I discovered the truth ...

Instead creating new application context, I just have to use the context from the current context ...

Here the right code :
CmsHttpContext.Current.SessionSettings.AutoFilterHidden = false;

and it works now !

Emmanuel
=?Utf-8?B?RW1tYW51ZWw=?=

2004-02-04, 10:46 am

Thanks Stefan for your answear.

Using CMS since a few weeks, you are an great source of informations.

I really appreciate your work and your sympathy !!!

Regards,

Emmanuel
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com