Microsoft Content Management Server - Channels.FilterByHidden does not find hidden channels

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > May 2005 > Channels.FilterByHidden does not find hidden channels





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 Channels.FilterByHidden does not find hidden channels
Microsoft

2005-05-23, 5:53 pm

I have created a hidden channel in which users can publish news articles.
These are then rendered by a user control which finds a channel with a
specific custom property and renders a summary about each of its postings.
The reason the channel is hidden is so that it is not visible in the
navigation.

I am trying to retrieve the channels but cannot get the hidden channel on
the published site. I am specifically setting Channels.FilterByHidden(true).
(EXample code below)
However, it seems that this only filters Postings and not channels, despite
the documentation.saying it filters Channel Items.

So, how do I get a listing of all child channels, including those that are
hidden?


Code:

public static Channel GetChildChannelByPropertyName(Channel channel, string
PropertyName, string PropertyValue)

{

Channel currentChannel = channel;

//check that we are not already at the required channel

CustomProperty currentProperty =
currentChannel.CustomProperties[PropertyName];

if (currentProperty != null)

{

if (String.Compare(currentProperty.Value, PropertyValue, true) == 0)

{

//We have a match on the custom property

//return the currentChannel

return currentChannel;

}

}

//iterate through the hidden child channels until we find a match

ChannelCollection childChannels = channel.Channels;

//Ensure that we see the Hidden channels

childChannels.FilterByHidden(true);

for (int i = 0; i < childChannels.Count; i++)

{

currentChannel = childChannels[i];

currentProperty = currentChannel.CustomProperties[PropertyName];

if (currentProperty != null)

{

if (String.Compare(currentProperty.Value, PropertyValue, true) == 0)

{

//We have a match on the custom property

//return the currentChannel

return currentChannel;

}

}

}

//No Matching channel found so return a null

return null;

}



Stefan [MSFT]

2005-05-23, 5:53 pm

Hi Dirk,

you need to set CmsHttpContext.Current.SessionSettings.AutoFilterHidden =
false.
After you are finished you need to set this back to true;

Cheers,
Stefan

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

New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------


"Microsoft" <dirc.khan-evans@eurorscgskybridge.com> wrote in message
news:OifKKy6XFHA.1384@TK2MSFTNGP09.phx.gbl...
>I have created a hidden channel in which users can publish news articles.
>These are then rendered by a user control which finds a channel with a
>specific custom property and renders a summary about each of its postings.
>The reason the channel is hidden is so that it is not visible in the
>navigation.
>
> I am trying to retrieve the channels but cannot get the hidden channel on
> the published site. I am specifically setting
> Channels.FilterByHidden(true). (EXample code below)
> However, it seems that this only filters Postings and not channels,
> despite the documentation.saying it filters Channel Items.
>
> So, how do I get a listing of all child channels, including those that are
> hidden?
>
>
> Code:
>
> public static Channel GetChildChannelByPropertyName(Channel channel,
> string PropertyName, string PropertyValue)
>
> {
>
> Channel currentChannel = channel;
>
> //check that we are not already at the required channel
>
> CustomProperty currentProperty =
> currentChannel.CustomProperties[PropertyName];
>
> if (currentProperty != null)
>
> {
>
> if (String.Compare(currentProperty.Value, PropertyValue, true) == 0)
>
> {
>
> //We have a match on the custom property
>
> //return the currentChannel
>
> return currentChannel;
>
> }
>
> }
>
> //iterate through the hidden child channels until we find a match
>
> ChannelCollection childChannels = channel.Channels;
>
> //Ensure that we see the Hidden channels
>
> childChannels.FilterByHidden(true);
>
> for (int i = 0; i < childChannels.Count; i++)
>
> {
>
> currentChannel = childChannels[i];
>
> currentProperty = currentChannel.CustomProperties[PropertyName];
>
> if (currentProperty != null)
>
> {
>
> if (String.Compare(currentProperty.Value, PropertyValue, true) == 0)
>
> {
>
> //We have a match on the custom property
>
> //return the currentChannel
>
> return currentChannel;
>
> }
>
> }
>
> }
>
> //No Matching channel found so return a null
>
> return null;
>
> }
>
>
>



Microsoft

2005-05-24, 6:02 pm

Thanks Stefan.. this solved my problem! Obscure or what?

"Stefan [MSFT]" <stefang@online.microsoft.com> wrote in message
news:uELyd46XFHA.2076@TK2MSFTNGP15.phx.gbl...
> Hi Dirk,
>
> you need to set CmsHttpContext.Current.SessionSettings.AutoFilterHidden =
> false.
> After you are finished you need to set this back to true;
>
> Cheers,
> Stefan
>


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com